Skip to content

Refactor designMode/innerText #5588

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 2, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 44 additions & 48 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -12272,12 +12272,11 @@ interface <dfn>DOMStringMap</dfn> {
</div>


<h4>The <code data-x="dom-innerText">innerText</code> IDL attribute</h4>
<h4 id="the-innertext-idl-attribute">The <code data-x="dom-innerText">innerText</code> getter and
setter</h4>

<dl class="domintro">

<dt><var>element</var> . <code subdfn data-x="dom-innerText">innerText</code> [ = <var>value</var> ]</dt>

<dd>
<p>Returns the element's text content "as rendered".</p>

Expand All @@ -12287,16 +12286,15 @@ interface <dfn>DOMStringMap</dfn> {

<div w-nodev>

<p>On getting, the <dfn><code data-x="dom-innerText">innerText</code></dfn> attribute must follow
these steps:</p>
<p>The <dfn><code data-x="dom-innerText">innerText</code></dfn> getter steps are:</p>

<ol>
<li>
<p>If this element is not <span>being rendered</span>, or if the user agent is a non-CSS user
agent, then return this element's <span>descendant text content</span>.</p>
<p>If <span>this</span> is not <span>being rendered</span> or if the user agent is a non-CSS
user agent, then return <span>this</span>'s <span>descendant text content</span>.</p>

<p class="note">This step can produce surprising results, as when the <code
data-x="dom-innerText">innerText</code> attribute is accessed on an element not <span>being
data-x="dom-innerText">innerText</code> getter is invoked on an element not <span>being
rendered</span>, its text contents are returned, but when accessed on an element that is
<span>being rendered</span>, all of its children that are not <span>being rendered</span> have
their text contents ignored.</p>
Expand All @@ -12305,7 +12303,7 @@ interface <dfn>DOMStringMap</dfn> {
<li><p>Let <var>results</var> be a new empty <span>list</span>.</p></li>

<li>
<p>For each child node <var>node</var> of this element:</p>
<p>For each child node <var>node</var> of <span>this</span>:</p>

<ol>
<li><p>Let <var>current</var> be the <span>list</span> resulting in running the <span>inner
Expand Down Expand Up @@ -12419,11 +12417,10 @@ interface <dfn>DOMStringMap</dfn> {
stringifier and maybe expose it directly on <span data-x="concept-range">ranges</span>. See <a
href="https://www.w3.org/Bugs/Public/show_bug.cgi?id=10583">Bugzilla bug 10583</a>.</p>

<p>On setting, the <code data-x="dom-innerText">innerText</code> attribute must follow these
steps:</p>
<p>The <code data-x="dom-innerText">innerText</code> setter steps are:</p>

<ol>
<li><p>Let <var>document</var> be this element's <span>node document</span>.</p></li>
<li><p>Let <var>document</var> be <span>this</span>'s <span>node document</span>.</p></li>

<li><p>Let <var>fragment</var> be a new <code>DocumentFragment</code> object whose <span>node
document</span> is <var>document</var>.</p></li>
Expand Down Expand Up @@ -12469,7 +12466,7 @@ interface <dfn>DOMStringMap</dfn> {
</li>

<li><p><span data-x="concept-node-replace-all">Replace all</span> with <var>fragment</var> within
this element.</p></li>
<span>this</span>.</p></li>
</ol>

</div>
Expand Down Expand Up @@ -73576,21 +73573,11 @@ body { display:none }



<h4>Making entire documents editable: the <code data-x="dom-document-designMode">designMode</code>
IDL attribute</h4>

<div w-nodev>

<p>Documents have a <dfn id="designMode"
data-x="dom-document-designMode"><code>designMode</code></dfn>, which can be either enabled or
disabled.</p>

</div>
<h4 id="making-entire-documents-editable:-the-designmode-idl-attribute">Making entire documents
editable: the <code data-x="dom-document-designMode">designMode</code> getter and setter</h4>

<dl class="domintro">

<dt><var>document</var> . <code subdfn data-x="dom-document-designMode">designMode</code> [ = <var>value</var> ]</dt>

<dd>
<p>Returns "<code data-x="">on</code>" if the document is editable, and "<code
data-x="">off</code>" if it isn't.</p>
Expand All @@ -73602,28 +73589,37 @@ body { display:none }

<div w-nodev>

<p>The <code data-x="dom-document-designMode">designMode</code> IDL attribute on the
<code>Document</code> object takes two values, "<code data-x="">on</code>" and "<code
data-x="">off</code>". On setting, the new value must be compared in an <span>ASCII
case-insensitive</span> manner to these two values; if it matches the "<code data-x="">on</code>"
value, then <code data-x="dom-document-designMode">designMode</code> must be enabled, and if it
matches the "<code data-x="">off</code>" value, then <code
data-x="dom-document-designMode">designMode</code> must be disabled. Other values must be
ignored.</p>
<p><code>Document</code> objects have an associated <dfn>design mode enabled</dfn>, which is a
boolean. It is initially false.</p>

<p>On getting, if <code data-x="dom-document-designMode">designMode</code> is enabled, the IDL
attribute must return the value "<code data-x="">on</code>"; otherwise it is disabled, and the
attribute must return the value "<code data-x="">off</code>".</p>
<p>The <dfn id="designMode"><code data-x="dom-document-designMode">designMode</code></dfn> getter
steps are to return "<code data-x="">on</code>" if <span>this</span>'s <span>design mode
enabled</span> is true; otherwise "<code data-x="">off</code>".</p>

<p>The last state set must persist until the document is destroyed or the state is changed.
Initially, documents must have their <code data-x="dom-document-designMode">designMode</code>
disabled.</p>
<p>The <code data-x="dom-document-designMode">designMode</code> setter steps are:</p>

<p>When the <code data-x="dom-document-designMode">designMode</code> changes from being disabled to
being enabled, the user agent must <span>immediately</span> reset the document's <span>active range</span>'s
start and end boundary points to be at the start of the <code>Document</code> and then run the
<span>focusing steps</span> for the <span>document element</span> of the <code>Document</code>, if
non-null.</p>
<ol>
<li><p>Let <var>value</var> be the given value, <span>converted to ASCII
lowercase</span>.</p></li>

<li>
<p>If <var>value</var> is "<code data-x="">on</code>" and <span>this</span>'s <span>design mode
enabled</span> is false, then:</p>

<ol>
<li><p>Set <span>this</span>'s <span>design mode enabled</span> to true.</p></li>

<li><p>Reset <span>this</span>'s <span>active range</span>'s start and end boundary points to
be at the start of <span>this</span>.</p></li>

<li><p>Run the <span>focusing steps</span> for <span>this</span>'s <span>document
element</span>, if non-null.</p></li>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional: this could have more cross-links and be more rigorous, e.g. https://dom.spec.whatwg.org/#concept-range-start and setting the offset to 0 instead of "the start of this".

</ol>
</li>

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: "If this's document element is non-null, then run the focusing steps for this's document element" would be much clearer IMO.

<li><p>If <var>value</var> is "<code data-x="">off</code>", then set <span>this</span>'s
<span>design mode enabled</span> to false.</p></li>
</ol>

</div>

Expand Down Expand Up @@ -73665,8 +73661,8 @@ body { display:none }
<p>An <dfn data-export="">editing host</dfn> is either an <span data-x="HTML elements">HTML
element</span> with its <code data-x="attr-contenteditable">contenteditable</code> attribute in
the <i>true</i> state, or a <span data-x="concept-tree-child">child</span> <span data-x="HTML
elements">HTML element</span> of a <code>Document</code> with <code
data-x="dom-document-designMode">designMode</code> enabled.</p>
elements">HTML element</span> of a <code>Document</code> whose <span>design mode enabled</span> is
true.</p>

<p>The definition of the terms <dfn
data-x-href="https://w3c.github.io/editing/execCommand.html#active-range">active range</dfn>, <dfn
Expand Down Expand Up @@ -121895,8 +121891,8 @@ INSERT INTERFACES HERE
href="https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document">W3C Permissive
Document License</a>.</p>

<p>Part of the revision history of the <code data-x="dom-innerText">innerText</code> IDL attribute
can be found in the <a
<p>Part of the revision history of the <code data-x="dom-innerText">innerText</code> getter and
setter can be found in the <a
href="https://github.com/rocallahan/innerText-spec"><code>rocallahan/innerText-spec</code>
repository</a>.</p>

Expand Down