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

Fix influence of <slot> on dir=auto computation of its shadow tree ancestors. #41584

Merged
merged 1 commit into from
Aug 22, 2023
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,65 @@
<title>HTML Test: dir=auto|rtl with slots, and direction should be RTL</title>
<meta charset="UTF-8">
<meta name="author" title="Miyoung Shin" href="mailto:myid.shin@igalia.com">
<meta name="assert" content="When dir='auto', the direction is set according to
slot's assigned node. And the direction should be propagated to shadow" />
<meta name="author" title="L. David Baron" href="mailto:dbaron@chromium.org">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#the-dir-attribute"/>
<link rel="help" href="/~https://github.com/whatwg/html/issues/3699">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="host1"><span></span></div>
<div id="host2" dir="rtl"></div>
<span id="host3" dir="auto"></span>
<div id="host4">اختبر</div>
<div id="host5"></div>
<div id="host6">اختبر</div>
<script>
let root1 = host1.attachShadow({mode:"open"});
root1.innerHTML = '<slot dir="rtl"></slot>';

let root2 = host2.attachShadow({mode:"open"});
root2.innerHTML = '<span></span>';
test(() => {
let root1 = host1.attachShadow({mode:"open"});
root1.innerHTML = '<slot dir="rtl"></slot>';
let span = host1.firstChild;
assert_equals(getComputedStyle(span).direction, "rtl");
assert_true(span.matches(":dir(ltr)"));
}, 'Slots: Directionality: dir=rtl on slot');

let root3 = host3.attachShadow({mode:"open"});
root3.innerHTML = `اختبر`;
test(() => {
let root2 = host2.attachShadow({mode:"open"});
root2.innerHTML = '<span></span>';
let span = root2.querySelector("span");
assert_equals(getComputedStyle(span).direction, "rtl");
assert_true(span.matches(":dir(rtl)"));
}, 'Slots: Directionality: dir=rtl on host');

let root4 = host4.attachShadow({mode:"open"});
root4.innerHTML = '<span dir="auto"><slot></slot></span>';
test(() => {
let root3 = host3.attachShadow({mode:"open"});
root3.innerHTML = `اختبر`;
let span = host3;
assert_equals(getComputedStyle(span).direction, "ltr");
assert_true(span.matches(":dir(ltr)"));
}, 'Slots: Directionality: dir=auto on host with Arabic shadow tree content');

let root5 = host5.attachShadow({mode:"open"});
test(() => {
let root4 = host4.attachShadow({mode:"open"});
root4.innerHTML = '<span dir="auto"><slot></slot></span>';
let span = root4.querySelector("span");
assert_equals(getComputedStyle(span).direction, "ltr");
assert_true(span.matches(":dir(ltr)"));
}, 'Slots: Directionality: dir=auto in shadow tree with Arabic light tree content');

test(() => {
let root5 = host5.attachShadow({mode:"open"});
root5.innerHTML = '<span dir="auto"><slot>اختبر</slot></span>';
let span = root5.querySelector("span");
assert_equals(getComputedStyle(span).direction, "rtl");
assert_true(span.matches(":dir(rtl)"));
}, 'Slots: Directionality: dir=auto in shadow tree with Arabic shadow tree content');

test(() => {
assert_equals(getComputedStyle(host1.firstChild).direction, "rtl");
assert_equals(getComputedStyle(root2.querySelector("span")).direction, "rtl");
assert_equals(getComputedStyle(host3).direction, "ltr");
assert_equals(getComputedStyle(root4.querySelector("span")).direction, "rtl");
assert_equals(getComputedStyle(root5.querySelector("span")).direction, "rtl");
}, 'Slots: Directionality');
let root6 = host6.attachShadow({mode:"open"});
root6.innerHTML = '<slot dir="auto"></slot>';
let span = root6.querySelector("slot");
assert_equals(getComputedStyle(span).direction, "rtl");
assert_true(span.matches(":dir(rtl)"));
}, 'Slots: Directionality: dir=auto on slot with Arabic light tree content');

</script>