-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
From https://rocallahan.github.io/innerText-spec/ with no normative changes except adding [CEReactions] to the IDL. Fixes #465.
- Loading branch information
Showing
1 changed file
with
150 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3450,6 +3450,7 @@ a.setAttribute('href', 'http://example.com/'); // change the content attribute d | |
<li>The <dfn data-noexport="" data-x-href="https://drafts.csswg.org/css2/visudet.html#propdef-vertical-align">'vertical-align'</dfn> property</li> | ||
<li>The <dfn data-noexport="" data-x-href="https://drafts.csswg.org/css2/generate.html#content">'content'</dfn> property</li> | ||
<li>The <dfn data-noexport="" data-x-href="https://drafts.csswg.org/css2/visuren.html#value-def-inline-block">'inline-block'</dfn> value of the <span>'display'</span> property</li> | ||
<li>The <dfn data-noexport="" data-x-href="https://drafts.csswg.org/css2/visufx.html#propdef-visibility">'visibility'</dfn> property</li> | ||
</ul> | ||
|
||
<p>The CSS specification also defines the following border properties: <ref spec=CSS></p> | ||
|
@@ -3544,6 +3545,10 @@ a.setAttribute('href', 'http://example.com/'); // change the content attribute d | |
<li>The <dfn data-noexport="" data-x-href="https://drafts.csswg.org/css-backgrounds/#position"><position></dfn> CSS data type</li> | ||
</ul> | ||
|
||
<p>The term <dfn data-noexport="" | ||
data-x-href="https://drafts.csswg.org/css-display/#block-level">block-level</dfn> is defined in | ||
the <cite>CSS Display</cite> specification. <ref spec=CSSDISPLAY></p> | ||
|
||
<p>The following features are defined in the <cite>CSS Fonts</cite> specification: <ref | ||
spec=CSSFONTS></p> | ||
|
||
|
@@ -3581,13 +3586,18 @@ a.setAttribute('href', 'http://example.com/'); // change the content attribute d | |
<ul class="brief"> | ||
<li>The <dfn data-noexport="" data-x-href="https://drafts.csswg.org/css-tables/#propdef-border-spacing">'border-spacing'</dfn> property</li> | ||
<li>The <dfn data-noexport="" data-x-href="https://drafts.csswg.org/css-tables/#border-collapse-property">'border-collapse'</dfn> property</li> | ||
<li>The <dfn data-noexport="" data-x-href="https://drafts.csswg.org/css-tables/#table-cell">'table-cell'</dfn> value of the <span>'display'</span> property</li> | ||
<li>The <dfn data-noexport="" data-x-href="https://drafts.csswg.org/css-tables/#table-cell">'table-cell'</dfn>, | ||
<dfn data-noexport="" data-x-href="https://drafts.csswg.org/css-tables/#table-row">'table-row'</dfn>, | ||
<dfn data-noexport="" data-x-href="https://drafts.csswg.org/css-tables/#table-caption">'table-caption'</dfn>, and | ||
<dfn data-noexport="" data-x-href="https://drafts.csswg.org/css-tables/#table">'table'</dfn> | ||
values of the <span>'display'</span> property</li> | ||
</ul> | ||
|
||
<p>The following features are defined in the <cite>CSS Text</cite> specification: | ||
<ref spec=CSSTEXT></p> | ||
|
||
<ul class="brief"> | ||
<li>The <dfn data-noexport="" data-x-href="https://drafts.csswg.org/css-text/#text-transform-property">'text-transform'</dfn> property</li> | ||
<li>The <dfn data-noexport="" data-x-href="https://drafts.csswg.org/css-text/#white-space-property">'white-space'</dfn> property</li> | ||
<li>The <dfn data-noexport="" data-x-href="https://drafts.csswg.org/css-text/#text-align-property">'text-align'</dfn> property</li> | ||
<li>The <dfn data-noexport="" data-x-href="https://drafts.csswg.org/css-text/#letter-spacing-property">'letter-spacing'</dfn> property</li> | ||
|
@@ -9651,6 +9661,8 @@ interface <dfn>HTMLElement</dfn> : <span>Element</span> { | |
[<span>CEReactions</span>] attribute <span>HTMLMenuElement</span>? <span data-x="dom-contextMenu">contextMenu</span>; | ||
[<span>CEReactions</span>] attribute boolean <span data-x="dom-spellcheck">spellcheck</span>; | ||
void <span data-x="dom-forceSpellCheck">forceSpellCheck</span>(); | ||
|
||
[<span>CEReactions</span>] attribute DOMString <span data-x="dom-innerText">innerText</span>; | ||
}; | ||
<span>HTMLElement</span> implements <span>GlobalEventHandlers</span>; | ||
<span>HTMLElement</span> implements <span>DocumentAndElementEventHandlers</span>; | ||
|
@@ -11962,6 +11974,133 @@ interface <dfn>DOMStringMap</dfn> { | |
</div> | ||
|
||
|
||
<h4>The <code data-x="dom-innerText">innerText</code> IDL attribute</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> | ||
|
||
<p>Can be set, to replace the element's children with the given value, but with linebreaks | ||
converted to <code>br</code> elements.</p> | ||
|
||
</dl> | ||
|
||
<div w-nodev> | ||
|
||
<p>On getting, the <dfn><code data-x="dom-innerText">innerText</code></dfn> attribute must follow | ||
these steps:</p> | ||
|
||
<ol> | ||
<li><p>If the element is not <span>being rendered</span>, return the same value as the | ||
<code>textContent</code> IDL attribute on the element.</p></li> | ||
|
||
<li> | ||
<p>Compute a list of items each of which is a string or a "required line break count", a | ||
positive integer, by applying the following recursive procedure to each child node | ||
<var>node</var> of the element in <span>tree order</span> and concatenating the results. | ||
(Intuitively, a "required line break count" item means that a certain number of line breaks must | ||
appear at that point, but they can be collapsed with the line breaks induced by adjacent | ||
"required line break count" items, reminiscient to CSS margin-collapsing.)</p> | ||
|
||
<ol> | ||
<li><p>Let <var>items</var> be the result of recursively applying this procedure to each child | ||
of <var>node</var> and concatenating the results (producing a list of items).</p></li> | ||
|
||
<li><p>If <var>node</var>'s <span>computed value</span> of <span>'visibility'</span> is not | ||
'visible', return <var>items</var>.</p></li> | ||
|
||
<li> | ||
<p>If <var>node</var> is a <code>Text</code> node child of an <code>rp</code> element, return | ||
a single string item containing the text of <var>node</var>. | ||
|
||
<p class="note">The <code>rp</code> element is normally 'display:none' but we want to include | ||
its text.</p> | ||
</li> | ||
|
||
<li> | ||
<p>If <var>node</var> has no associated CSS box, return <var>items</var>.</p> | ||
|
||
<p class="note"><var>items</var> can be non-empty due to 'display:contents'.</p> | ||
</li> | ||
|
||
<li><p>If <var>node</var> is a <code>Text</code> node, then for each CSS text box produced by | ||
<var>node</var>, in content order, compute the text of the box after application of the CSS | ||
<span>'white-space'</span> processing rules and <span>'text-transform'</span> rules, and return | ||
a list of the resulting strings. The CSS <span>'white-space'</span> processing rules are | ||
slightly modified: collapsible spaces at the end of lines are always collapsed, but they are | ||
only removed if the line is the last line of the block, or it ends with a <code>br</code> | ||
element. Soft hyphens should be preserved. <ref spec=CSSTEXT></p></li> | ||
|
||
<li><p>If <var>node</var> is a <code>br</code> element, append a string containing a single | ||
U+000A LINE FEED (LF) character to <var>items</var>. | ||
|
||
<li><p>If <var>node</var>'s <span>computed value</span> of <span>'display'</span> is | ||
<span>'table-cell'</span>, and <var>node</var>'s CSS box is not the last | ||
<span>'table-cell'</span> box of its enclosing 'table-row' box, append a string containing a | ||
single U+0009 CHARACTER TABULATION (tab) character to <var>items</var>.</p></li> | ||
|
||
<li><p>If <var>node</var>'s <span>computed value</span> of <span>'display'</span> is | ||
<span>'table-row'</span>, and <var>node</var>'s CSS box is not the last | ||
<span>'table-row'</span> box of the nearest ancestor <span>'table'</span> box, append a string | ||
containing a single U+000A LINE FEED (LF) character to <var>items</var>.</p></li> | ||
|
||
<li><p>If <var>node</var> is a <code>p</code> element, add a "required line break count of 2" | ||
item at the beginning and end of <var>items</var>.</p></li> | ||
|
||
<li> | ||
<p>If <var>node</var>'s <span>used value</span> of <span>'display'</span> is | ||
<span>block-level</span> or <span>'table-caption'</span>, add a "required line break count of | ||
1" item at the beginning and end of <var>items</var>. <ref spec=CSSDISPLAY></p> | ||
|
||
<p class="note">Floats and absolutely-positioned elements fall into this category.</p> | ||
</li> | ||
|
||
<li><p>Return <var>items</var>.</p></li> | ||
</ol> | ||
</li> | ||
|
||
<li><p>Delete any string items whose strings are empty.</p></li> | ||
|
||
<li><p>Delete any runs of consecutive "required line break count" items at the start or end of | ||
the list.</p></li> | ||
|
||
<li><p>Replace each remaining run of consecutive "required line break count" items with a string | ||
consisting of as many U+000A LINE FEED (LF) characters as the maximum of the values in the | ||
"required line break count" items.</p></li> | ||
|
||
<li><p>Return the concatenation of the string items.</p></li> | ||
</ol> | ||
|
||
<p class="note">Note that descendant nodes of most replaced elements (e.g. <code>textarea</code>, | ||
<code>select</code>, and <code>video</code> — but not <code>button</code>) are not rendered | ||
by CSS, strictly speaking, and therefore have no CSS boxes for the purposes of this algorithm.</p> | ||
|
||
<p class="big-issue">This algorithm is amenable to being generalized to work on a <span | ||
data-x="concept-range">ranges</span>. Then we can use it as the basis for <code>Selection</code>'s | ||
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 replace the child | ||
nodes of the element with new child nodes created as follows, processing the string in order:</p> | ||
|
||
<ol> | ||
<li><p>For each run of text not including U+000D CARRIAGE RETURN (CR) or U+000A LINE FEED (LF), | ||
create a <code>Text</code> node containing that text.</p></li> | ||
|
||
<li><p>For each U+000D CARRIAGE RETURN U+000A LINE FEED (CRLF) character pair, create a | ||
<code>br</code> element.</p></li> | ||
|
||
<li><p>For each U+000D CARRIAGE RETURN (CR) or U+000A LINE FEED (LF) character not part of a | ||
U+000D CARRIAGE RETURN U+000A LINE FEED (CRLF) character pair, create a <code>br</code> | ||
element.</p></li> | ||
</ol> | ||
|
||
</div> | ||
|
||
<h4>Requirements relating to the bidirectional algorithm</h4> | ||
|
||
<div w-nodev> | ||
|
@@ -118617,6 +118756,9 @@ INSERT INTERFACES HERE | |
<dt id="refsCSSCOLOR">[CSSCOLOR]</dt> | ||
<dd><cite><a href="https://drafts.csswg.org/css-color/">CSS Color Module Level 3</a></cite>, T. Çelik, C. Lilley, L. Baron. W3C.</dd> | ||
|
||
<dt id="refsCSSDISPLAY">[CSSDISPLAY]</dt> | ||
<dd><cite><a href="https://drafts.csswg.org/css-font-loading/">CSS Display</a></cite>, T. Atkins, E. Etemad. W3C.</dd> | ||
|
||
<dt id="refsCSSFONTLOAD">[CSSFONTLOAD]</dt> | ||
<dd><cite><a href="https://drafts.csswg.org/css-font-loading/">CSS Font Loading</a></cite>, T. Atkins, J. Daggett. W3C.</dd> | ||
|
||
|
@@ -119949,6 +120091,13 @@ INSERT INTERFACES HERE | |
href="https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document">W3C Permissive | ||
Document License</a>.</p> | ||
|
||
<p itemscope itemtype="http://n.whatwg.org/work">Part of the revision history of the <code | ||
data-x="dom-innerText">innerText</code> IDL attribute can be found in the <a | ||
href="https://github.com/rocallahan/innerText-spec"><code>rocallahan/innerText-spec</code> | ||
repository</a>, which is available under the <a itemprop="license" | ||
href="https://creativecommons.org/licenses/by/3.0/">Creative Commons Attribution 3.0 | ||
License</a>.</p> | ||
|
||
<p>For about ten years starting in 2003, this specification was almost entirely written by Ian | ||
Hickson (Google, [email protected]). More recently, Simon Pieters (Opera, [email protected]), Anne van | ||
Kesteren (Mozilla, [email protected]), Philip Jägenstedt (Google, [email protected]), and | ||
|