From b73abec846dc498ef0f725c61d1aa2cb52d00748 Mon Sep 17 00:00:00 2001 From: "L. David Baron" Date: Wed, 18 Oct 2023 11:23:14 -0700 Subject: [PATCH] Test inside dir=auto, and fix a dir=auto invalidation case. This fixes a TODO, and tests the spec editing fix proposed in https://github.com/whatwg/html/pull/9853. It then fixes an invalidation case for insertion/removal of elements that shows up in that added test, and also adjusts one existing test's result to match that fix. Bug: 576815 Change-Id: I5ce68b1cc9b9b8684a9abaf494c5624601f601bc Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4952754 Commit-Queue: David Baron Reviewed-by: Di Zhang Cr-Commit-Position: refs/heads/main@{#1211624} --- .../dir-slots-directionality.html | 35 +++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/html/dom/elements/global-attributes/dir-slots-directionality.html b/html/dom/elements/global-attributes/dir-slots-directionality.html index 5e8cedb9c156f7..db783fc55ca349 100644 --- a/html/dom/elements/global-attributes/dir-slots-directionality.html +++ b/html/dom/elements/global-attributes/dir-slots-directionality.html @@ -51,8 +51,8 @@ let root5 = host5.attachShadow({mode:"open"}); root5.innerHTML = 'اختبر'; let span = root5.querySelector("span"); - assert_equals(getComputedStyle(span).direction, "rtl"); - assert_true(span.matches(":dir(rtl)")); + assert_equals(getComputedStyle(span).direction, "ltr"); + assert_true(span.matches(":dir(ltr)")); }, 'Slots: Directionality: dir=auto in shadow tree with Arabic shadow tree content'); test(() => { @@ -63,4 +63,35 @@ assert_true(span.matches(":dir(rtl)")); }, 'Slots: Directionality: dir=auto on slot with Arabic light tree content'); +test(() => { + let host = document.createElement("div"); + host.dir = "rtl"; + document.body.appendChild(host); + let root = host.attachShadow({mode:"open"}); + root.innerHTML = '
A
'; + let div = root.querySelector("div"); + assert_true(div.matches(":dir(rtl)")); + host.remove(); +}, 'slot provides its directionality (from host) to a dir=auto container'); + +test(() => { + let host = document.createElement("div"); + document.body.appendChild(host); + let root = host.attachShadow({mode:"open"}); + root.innerHTML = '
A\u05D0
'; + let div = root.querySelector("div"); + assert_true(div.matches(":dir(rtl)")); + host.remove(); +}, 'children with dir attribute are skipped by dir=auto'); + +test(() => { + let host = document.createElement("div"); + document.body.appendChild(host); + let root = host.attachShadow({mode:"open"}); + root.innerHTML = '
\u05D0
'; + let div = root.querySelector("div"); + assert_true(div.matches(":dir(rtl)")); + host.remove(); +}, 'slot with dir attribute is skipped by dir=auto'); +