Skip to content

Commit

Permalink
Make dir=auto and dirname apply to more form controls
Browse files Browse the repository at this point in the history
This makes two changes:

* Applies the auto directionality algorithm to Hidden, Password, Submit Button, Reset Button, and Button input elements.
* Adds support for the dirname attribute to Password and Submit Button input elements.

And it uses a shared concept between these two features so they will no longer diverge going forward. (The concept can still be shared despite Reset Button and Button input elements not supporting the dirname attribute as the concept is only consulted in form submission where those elements have already been filtered out.)

Tests: web-platform-tests/wpt#42427

Fixes #3330 and fixes #9669.
  • Loading branch information
annevk authored Oct 24, 2023
1 parent 0d0ac9f commit 11114d0
Showing 1 changed file with 27 additions and 17 deletions.
44 changes: 27 additions & 17 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -13578,6 +13578,8 @@ Transport Protocol">HTTP&lt;/abbr> today.&lt;/p></code></pre> <!-- DO NOT REWRAP
data-x="attr-input-type">type</code> attribute is in the <span
data-x="attr-input-type-tel">Telephone</span> state, then return '<span
data-x="concept-ltr">ltr</span>'.</p></li>
<!-- This looks odd, but is very much deliberate:
https://www.w3.org/Bugs/Public/show_bug.cgi?id=17835 -->

<li><p>Return the <span>parent directionality</span> of <var>element</var>.</p></li>
</ol>
Expand All @@ -13588,16 +13590,27 @@ Transport Protocol">HTTP&lt;/abbr> today.&lt;/p></code></pre> <!-- DO NOT REWRAP
<span>HTML elements</span>, it cannot be present on elements from other namespaces. Thus, elements
from other namespaces always end up using the <span>parent directionality</span>.</p>

<p>The <dfn>auto-directionality form-associated elements</dfn> are:

<ul>
<li><p><code>input</code> elements whose <code data-x="attr-input-type">type</code> attribute is
in the <span data-x="attr-input-type-hidden">Hidden</span>, <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>, <span data-x="attr-input-type-email">Email</span>, <span
data-x="attr-input-type-password">Password</span>, <span data-x="attr-input-type-submit">Submit
Button</span>, <span data-x="attr-input-type-reset">Reset Button</span>, or <span
data-x="attr-input-type-button">Button</span> state, and</p></li>

<li><p><code>textarea</code> elements.</p></li>
</ul>

<p>To compute the <dfn>auto directionality</dfn> given an element <var>element</var>:</p>

<ol>
<li>
<p>If <var>element</var> 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, or <var>element</var> is a <code>textarea</code> element, then:</p>
<p>If <var>element</var> is an <span data-x="auto-directionality form-associated
elements">auto-directionality form-associated element</span>:

<ol>
<li><p>If <var>element</var>'s <span data-x="concept-fe-value">value</span> contains a
Expand Down Expand Up @@ -46552,7 +46565,7 @@ interface <dfn interface>HTMLInputElement</dfn> : <span>HTMLElement</span> {
<!-- <td class="yes"> Yes Search -->
<td class="yes"> Yes <!-- Telephone, URL -->
<td class="yes"> Yes <!-- Email -->
<td class="no"> &middot; <!-- Password -->
<td class="yes"> Yes <!-- Password -->
<td class="no"> &middot; <!-- Date -->
<!-- <td class="no"> &middot; Month -->
<!-- <td class="no"> &middot; Week -->
Expand All @@ -46564,7 +46577,7 @@ interface <dfn interface>HTMLInputElement</dfn> : <span>HTMLElement</span> {
<td class="no"> &middot; <!-- Checkbox -->
<!-- <td class="no"> &middot; Radio Button -->
<td class="no"> &middot; <!-- File Upload -->
<td class="no"> &middot; <!-- Submit Button -->
<td class="yes"> Yes <!-- Submit Button -->
<td class="no"> &middot; <!-- Image Button -->
<td class="no"> &middot; <!-- Reset Button -->
<!-- <td class="no"> &middot; Button -->
Expand Down Expand Up @@ -48557,6 +48570,7 @@ ldh-str = &lt; as defined in <a href="https://www.rfc-editor.org/rfc/rfc10
<p>The following common <code>input</code> element content
attributes, IDL attributes, and methods <span data-x="concept-input-apply">apply</span> to the element:
<code data-x="attr-fe-autocomplete">autocomplete</code>,
<code data-x="attr-fe-dirname">dirname</code>,
<code data-x="attr-input-maxlength">maxlength</code>,
<code data-x="attr-input-minlength">minlength</code>,
<code data-x="attr-input-pattern">pattern</code>,
Expand All @@ -48583,7 +48597,6 @@ ldh-str = &lt; as defined in <a href="https://www.rfc-editor.org/rfc/rfc10
<code data-x="attr-input-accept">accept</code>,
<code data-x="attr-input-alt">alt</code>,
<code data-x="attr-input-checked">checked</code>,
<code data-x="attr-fe-dirname">dirname</code>,
<code data-x="attr-fs-formaction">formaction</code>,
<code data-x="attr-fs-formenctype">formenctype</code>,
<code data-x="attr-fs-formmethod">formmethod</code>,
Expand Down Expand Up @@ -50550,6 +50563,7 @@ ldh-str = &lt; as defined in <a href="https://www.rfc-editor.org/rfc/rfc10

<p>The following common <code>input</code> element content attributes and IDL attributes <span
data-x="concept-input-apply">apply</span> to the element:
<code data-x="attr-fe-dirname">dirname</code>,
<code data-x="attr-fs-formaction">formaction</code>,
<code data-x="attr-fs-formenctype">formenctype</code>,
<code data-x="attr-fs-formmethod">formmethod</code>,
Expand All @@ -50568,7 +50582,6 @@ ldh-str = &lt; as defined in <a href="https://www.rfc-editor.org/rfc/rfc10
<code data-x="attr-input-alt">alt</code>,
<code data-x="attr-fe-autocomplete">autocomplete</code>,
<code data-x="attr-input-checked">checked</code>,
<code data-x="attr-fe-dirname">dirname</code>,
<code data-x="attr-dim-height">height</code>,
<code data-x="attr-input-list">list</code>,
<code data-x="attr-input-max">max</code>,
Expand Down Expand Up @@ -59664,13 +59677,9 @@ fur

<li>
<p>If the element has a <code data-x="attr-fe-dirname">dirname</code> attribute, that
attribute's value is not the empty string, and the element is either a <code>textarea</code>
element or an <code>input</code> element whose <code data-x="attr-input-type">type</code>
attribute is in the <span data-x="attr-input-type-hidden">Hidden</span>,
<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, then:</p>
attribute's value is not the empty string, and the element is an <span
data-x="auto-directionality form-associated elements">auto-directionality form-associated
element</span>:

<ol>
<li><p>Let <var>dirname</var> be the value of the element's <code
Expand Down Expand Up @@ -140701,6 +140710,7 @@ INSERT INTERFACES HERE
Jon Perlow,
Jonas Sicking,
Jonathan Cook,
Jonathan Kew,
Jonathan Neal,
Jonathan Oddy,
Jonathan Rees,
Expand Down

0 comments on commit 11114d0

Please sign in to comment.