Skip to content
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

Editorial rework of directionality #9452

Closed
wants to merge 4 commits into from
Closed
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
185 changes: 97 additions & 88 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -13358,23 +13358,16 @@ Transport Protocol">HTTP&lt;/abbr> today.&lt;/p></code></pre> <!-- DO NOT REWRAP
<dl>
<dt>The <dfn attr-value for="html-global/dir"><code data-x="attr-dir-ltr">ltr</code></dfn>
keyword, which maps to the <dfn data-x="attr-dir-ltr-state">ltr</dfn> state</dt>

<dd>
<p>Indicates that the contents of the element are explicitly directionally isolated
left-to-right text.</p>
</dd>
<dd><p>Indicates that the contents of the element are explicitly directionally isolated
left-to-right text.</p></dd>

<dt>The <dfn attr-value for="html-global/dir"><code data-x="attr-dir-rtl">rtl</code></dfn>
keyword, which maps to the <dfn data-x="attr-dir-rtl-state">rtl</dfn> state</dt>

<dd>
<p>Indicates that the contents of the element are explicitly directionally isolated
right-to-left text.</p>
</dd>
<dd><p>Indicates that the contents of the element are explicitly directionally isolated
right-to-left text.</p></dd>

<dt>The <dfn attr-value for="html-global/dir"><code data-x="attr-dir-auto">auto</code></dfn>
keyword, which maps to the <dfn data-x="attr-dir-auto-state">auto</dfn> state</dt>

<dd>
<p>Indicates that the contents of the element are explicitly directionally isolated text, but
that the direction is to be determined programmatically using the contents of the element (as
Expand All @@ -13391,7 +13384,8 @@ Transport Protocol">HTTP&lt;/abbr> today.&lt;/p></code></pre> <!-- DO NOT REWRAP
</dd>
</dl>

<p>The attribute has no <i data-x="invalid value default">invalid value default</i> and no <i data-x="missing value default">missing value default</i>.</p>
<p>The attribute has no <i data-x="invalid value default">invalid value default</i> and no <i
data-x="missing value default">missing value default</i>.</p>

<hr>

Expand All @@ -13401,107 +13395,108 @@ Transport Protocol">HTTP&lt;/abbr> today.&lt;/p></code></pre> <!-- DO NOT REWRAP
the following list:</p>

<dl class="switch">


<dt>If the element's <code data-x="attr-dir">dir</code> attribute is in the <span
data-x="attr-dir-ltr-state">ltr</span> state</dt>

<dt>If the element is a <span>document element</span> and the <code data-x="attr-dir">dir</code>
attribute is not in a defined state (i.e. it is not present or has an invalid value)</dt>

<dt>If the element is an <code>input</code> element whose <code
data-x="attr-input-type">type</code> attribute is in the <span
data-x="attr-input-type-tel">Telephone</span> state, and the <code data-x="attr-dir">dir</code>
attribute is not in a defined state (i.e. it is not present or has an invalid value)</dt>

<dd><p><span>The directionality</span> of the element is '<span
data-x="concept-ltr">ltr</span>'.</p></dd>


<dt>If the element's <code data-x="attr-dir">dir</code> attribute is in the <span
data-x="attr-dir-rtl-state">rtl</span> state</dt>

<dd><p><span>The directionality</span> of the element is '<span
data-x="concept-rtl">rtl</span>'.</p></dd>

<dt>If the element is an <code>input</code> element whose <code
data-x="attr-input-type">type</code> attribute is in the <span
data-x="attr-input-type-text">Text</span>, <span data-x="attr-input-type-search">Search</span>,
<span data-x="attr-input-type-tel">Telephone</span>, <span
data-x="attr-input-type-url">URL</span>, or <span data-x="attr-input-type-email">Email</span>
state, and the <code data-x="attr-dir">dir</code> attribute is in the <span
data-x="attr-dir-auto-state">auto</span> state</dt>

<dt>If the element is a <code>textarea</code> element and the <code data-x="attr-dir">dir</code>
attribute is in the <span data-x="attr-dir-auto-state">auto</span> state</dt>

<dd>
<p>If the element's <span data-x="concept-fe-value">value</span> contains a character of
bidirectional character type AL or R, and there is no character of bidirectional character type
L anywhere before it in the element's <span data-x="concept-fe-value">value</span>, then
<span>the directionality</span> of the element is '<span data-x="concept-rtl">rtl</span>'. <ref spec=BIDI></p>

<p>Otherwise, if the element's <span data-x="concept-fe-value">value</span> is not the empty
string, or if the element is a <span>document element</span>, <span>the directionality</span> of
the element is '<span data-x="concept-ltr">ltr</span>'.</p>

<p>Otherwise, <span>the directionality</span> of the element is the same as the element's parent
element's <span data-x="the directionality">directionality</span>.</p>
</dd>



<dt>If the element's <code data-x="attr-dir">dir</code> attribute is in the <span
data-x="attr-dir-auto-state">auto</span> state</dt>

<dt>If the element is a <code>bdi</code> element and the <code data-x="attr-dir">dir</code>
attribute is not in a defined state (i.e. it is not present or has an invalid value)</dt>

<dd>
<p>Find the first character in <span>tree order</span> that matches the following criteria:</p>

<ul>

<li><p>The character is from a <code>Text</code> node that is a descendant of the element whose
<span data-x="the directionality">directionality</span> is being determined.</p></li>
<p>The element's <span data-x="the directionality">directionality</span> is determined as
follows:</p>

<li><p>The character is of bidirectional character type L, AL, or R. <ref spec=BIDI></li>
<dl class="switch">
<dt>If the element is an <code>input</code> element whose <code
data-x="attr-input-type">type</code> attribute is in the <span
data-x="attr-input-type-text">Text</span>, <span data-x="attr-input-type-search">Search</span>,
<span data-x="attr-input-type-tel">Telephone</span>, <span
data-x="attr-input-type-url">URL</span>, or <span
bkardell marked this conversation as resolved.
Show resolved Hide resolved
data-x="attr-input-type-email">Email</span> state</dt>
<dt>If the element is a <code>textarea</code> element</dt>
<dd>
<p>The element's <span data-x="the directionality">directionality</span> is determined
as follows:</p>
bkardell marked this conversation as resolved.
Show resolved Hide resolved

<li>
<p>The character is not in a <code>Text</code> node that has an ancestor element that is a
descendant of the element whose <span data-x="the directionality">directionality</span> is
being determined and that is either:</p>
<dl class="switch">
<dt>If the element's <span data-x="concept-fe-value">value</span> contains a character of
bidirectional character type AL or R, and there is no character of bidirectional character
type L anywhere before it in the element's <span data-x="concept-fe-value">value</span></dt>
<dd><span>The directionality</span> of the element is '<span
data-x="concept-rtl">rtl</span>' <ref spec=BIDI>.

<ul class="brief">
<li>A <code>bdi</code> element.
<li>A <code>script</code> element.
<li>A <code>style</code> element.
<li>A <code>textarea</code> element.
<li>An element with a <code data-x="attr-dir">dir</code> attribute in a defined state.
</ul>
</li>
<dt>If the element's <span data-x="concept-fe-value">value</span> is the empty string, or if
bkardell marked this conversation as resolved.
Show resolved Hide resolved
the element has no parent element</dt>
bkardell marked this conversation as resolved.
Show resolved Hide resolved
<dd><span>The directionality</span> of the element is '<span
bkardell marked this conversation as resolved.
Show resolved Hide resolved
data-x="concept-ltr">ltr</span>'.</dd>

</ul>
<dt>Otherwise</dt>
<dd><span>The directionality</span> of the element is the same as the element's parent
element's <span data-x="the directionality">directionality</span>.</dd>
</dl>
</dd>

<p>If such a character is found and it is of bidirectional character type AL or R, <span>the
directionality</span> of the element is '<span data-x="concept-rtl">rtl</span>'.</p>
<dt>Otherwise</dt>
<dd>
<p><span>The directionality</span> is determined from the element's contents as follows:</p>

<p>If such a character is found and it is of bidirectional character type L, <span>the
directionality</span> of the element is '<span data-x="concept-ltr">ltr</span>'.</p>
<ol>
<li><p>Let <var>b</var> be the first (in <span>tree order</span>) <span>bidi-available</span>
<span>strong character</span> found among its <code>Text</code> nodes (including their
descendants).</p></li>

<p>Otherwise, if the element is a <span>document element</span>, <span>the directionality</span>
of the element is '<span data-x="concept-ltr">ltr</span>'.</p>
<li>
<p>Determine <span>the directionality</span> from <var>b</var> as follows:</p>

<p>Otherwise, <span>the directionality</span> of the element is the same as the element's parent
element's <span data-x="the directionality">directionality</span>.</p>
<dl class="switch">
<dt>If <var>b</var> is a character is of bidirectional character type AL or R</dt>
<dd><span>The directionality</span> of the element is '<span
data-x="concept-rtl">rtl</span>'.</dd>

<dt>If <var>b</var> is a character is of bidirectional character type L</dt>
<dd><span>The directionality</span> of the element is '<span
data-x="concept-ltr">ltr</span>'.</dd>

<dt>If <var>b</var> is not found</dt>
<dd><span>The directionality</span> of the element is the same as if the element's <code
data-x="attr-dir">dir</code> attribute were not in a defined state (and the element were
not a <code>bdi</code> element).</dd>
Comment on lines +13467 to +13470
Copy link
Member

Choose a reason for hiding this comment

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

This is very different from the current requirements for this state.

Contrast https://html.spec.whatwg.org/multipage/dom.html#the-directionality with https://whatpr.org/html/9452/dom.html#the-directionality. How is this not a normative change?

It's also not a great way to define things as when you implement this, you'd realize at this point that you probably need your code to branch differently.

</dl>
</li>
</ol>
</dd>
</dl>
</dd>

<dt>If the <code data-x="attr-dir">dir</code> attribute is not in a defined state (i.e., it is
not present or has an invalid value)</dt>
<dd>
<p>The element's <span data-x="the directionality">directionality</span> is determined as
follows:</p>

<dl class="switch">
<dt>If the element is an <code>input</code> element whose <code
data-x="attr-input-type">type</code> attribute is in the <span
data-x="attr-input-type-tel">Telephone</span> state</dt>
<dd><p><span>The directionality</span> of the element is '<span
data-x="concept-ltr">ltr</span>'.</p></dd>

<dt>If the element has a parent element and the <code data-x="attr-dir">dir</code> attribute is
not in a defined state (i.e. it is not present or has an invalid value)</dt>
<dt>If the element has a parent element</dt>
<dd><p><span>The directionality</span> of the element is the same as its parent element's <span
data-x="the directionality">directionality</span>.</p></dd>

<dd><p><span>The directionality</span> of the element is the same as the element's parent
element's <span data-x="the directionality">directionality</span>.</p></dd>
<dt>Otherwise</dt>
<dd><p><span>The directionality</span> of the element is "<code
data-x="concept-ltr">ltr</code>".</p></dd>
</dl>
</dd>
</dl>

<p class="note">Since the <code data-x="attr-dir">dir</code> attribute is only defined for
Expand All @@ -13511,10 +13506,24 @@ Transport Protocol">HTTP&lt;/abbr> today.&lt;/p></code></pre> <!-- DO NOT REWRAP
default to '<span data-x="concept-ltr">ltr</span>'.</p>

<div w-nodev>
<p class="note">This attribute <a href="#bidireq">has rendering requirements involving the
bidirectional algorithm</a>.</p>

<p class="note">This attribute <a href="#bidireq">has rendering requirements involving the
bidirectional algorithm</a>.</p>
<p>A <span>strong character</span> is <dfn>bidi-available</dfn> to an element <var>E</var> whose
<span data-x="the directionality">directionality</span> is being determined only if it does
<em>not</em> have an ancestor element that is both a descendant of <var>E</var> and also a
<dfn>bidi-excluded element</dfn>:</p>

<ul class="brief">
<li>A <code>bdi</code> element.</li>
<li>A <code>script</code> element.</li>
<li>A <code>style</code> element.</li>
<li>A <code>textarea</code> element.</li>
<li>An element with a <code data-x="attr-dir">dir</code> attribute in a defined state.</li>
</ul>

<p>A character is a <dfn>strong character</dfn> if the character is of bidirectional character
type L, AL, or R. <ref spec=BIDI></p>
</div>

<hr>
bkardell marked this conversation as resolved.
Show resolved Hide resolved
Expand Down