Skip to content

Commit

Permalink
Revert recent changes to rendering of <slot>
Browse files Browse the repository at this point in the history
As well as some of the corresponding changes to its directionality and language.

This reverts recent changes to the rendering section for the slot
element that I made recently in 1dc4c7557f5a4c879c1ce65b9cb59b91310bbf5
(PR #9796, fixing #3699). These changes had specified that all slot
elements, even those without a dir attribute, specify the direction and
unicode-bidi properties.

When I attempted to implement these changes, I discovered that they
broke a significant number of web-platform-tests, due to a pattern that
makes me suspect they would pose a compatibility problem. In
particular, specifying the CSS direction property for all slot elements
breaks inheritance of CSS direction into slotted elements, including
those in user-agent shadow DOM. (This makes a clearly visible change
when elements are implemented in terms of user-agent shadow DOM, which
probably is not intended.)

While I realize that the recommended practice is to specify the HTML dir
attribute rather than the CSS direction property, I believe the CSS
direction property is used enough that this is not acceptable.
(https://chromestatus.com/metrics/css/timeline/popularity/3 says the
property is used on around 40% of page loads. While the number of
interesting uses is probably substantially lower, it's also probably
still significant.)
  • Loading branch information
dbaron committed Jan 24, 2024
1 parent 8b404d4 commit 0c6f327
Showing 1 changed file with 6 additions and 13 deletions.
19 changes: 6 additions & 13 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -13341,8 +13341,6 @@ Transport Protocol">HTTP&lt;/abbr> today.&lt;/p></code></pre> <!-- DO NOT REWRAP
<dd><p>Use the value of that attribute.</p></dd>

<dt>If the node's parent is a <span>shadow root</span></dt>
<dt>If the node is a <code>slot</code> element whose <span>root</span> is a <span>shadow
root</span></dt>
<dd><p>Use the <span>language</span> of that <span>shadow root</span>'s <span
data-x="concept-DocumentFragment-host">host</span>.</p></dd>

Expand Down Expand Up @@ -13718,7 +13716,8 @@ Transport Protocol">HTTP&lt;/abbr> today.&lt;/p></code></pre> <!-- DO NOT REWRAP

<li><p>If <var>descendant</var> is a <code>slot</code> element whose <span>root</span> is a
<span>shadow root</span>, then return the <span data-x="the
directionality">directionality</span> of <var>descendant</var>.</p></li>
directionality">directionality</span> of that <span>shadow root</span>'s <span
data-x="concept-DocumentFragment-host">host</span>.</p></li>

<li><p>If <var>descendant</var> is not a <code>Text</code> node, then
<span>continue</span>.</p></li>
Expand Down Expand Up @@ -13754,11 +13753,6 @@ Transport Protocol">HTTP&lt;/abbr> today.&lt;/p></code></pre> <!-- DO NOT REWRAP
<p>To compute the <dfn>parent directionality</dfn> given an element <var>element</var>:</p>

<ol>
<li><p>If <var>element</var> is a <code>slot</code> element whose <span>root</span> is a
<span>shadow root</span>, then return the <span data-x="the directionality">directionality</span>
of <var>element</var>'s <span>root</span>'s <span
data-x="concept-DocumentFragment-host">host</span>.</p></li>

<li><p>Let <var>parentNode</var> be <var>element</var>'s parent node.</p></li>

<li><p>If <var>parentNode</var> is a <span>shadow root</span>, then return the <span data-x="the
Expand Down Expand Up @@ -131375,16 +131369,15 @@ br[clear=all i], br[clear=both i] { clear: both; }</code></pre>

<pre><code class="css">@namespace "http://www.w3.org/1999/xhtml";

[dir]:dir(ltr), slot:dir(ltr), bdi:dir(ltr), input[type=tel i]:dir(ltr) { direction: ltr; }
[dir]:dir(rtl), slot:dir(rtl), bdi:dir(rtl) { direction: rtl; }
[dir]:dir(ltr), bdi:dir(ltr), input[type=tel i]:dir(ltr) { direction: ltr; }
[dir]:dir(rtl), bdi:dir(rtl) { direction: rtl; }

address, blockquote, center, div, figure, figcaption, footer, form, header, hr,
legend, listing, main, p, plaintext, pre, summary, xmp, article, aside, h1, h2,
h3, h4, h5, h6, hgroup, nav, section, search, table, caption, colgroup, col,
thead, tbody, tfoot, tr, td, th, dir, dd, dl, dt, menu, ol, ul, li, bdi, output,
slot, [dir=ltr i], [dir=rtl i], [dir=auto i] {
unicode-bidi: isolate; <!-- anything that's similar to display:block, plus
<bdi>, <output>, <slot>, and dir="" -->
[dir=ltr i], [dir=rtl i], [dir=auto i] {
unicode-bidi: isolate; <!-- anything that's similar to display:block, plus <bdi>, <output>, and dir="" -->
}

bdo, bdo[dir] { unicode-bidi: isolate-override; } <!-- bdo[dir] rule is to override the otherwise higher-specificity attribute selectors in the previous rule -->
Expand Down

0 comments on commit 0c6f327

Please sign in to comment.