Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Added shadow directionality to the dir attribute algorithm #7424
Added shadow directionality to the dir attribute algorithm #7424
Changes from 3 commits
fe78255
b3bdb24
d46d084
b24d8e2
3cf5ac7
b7b84e8
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a benefit to tackling language in the same PR? Do we have tests for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. They need to work together. (And were part of the proposal that was accepted).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do they work together?
And are there tests for that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you have one set of rules for inheriting language, and a different set for inheriting direction, and you're working with French and Arabic, you're going to end up with elements that have
lang=ar dir=ltr
orlang=fr dir-rtl
, and this is clearly nonsensical.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’ll check on the state of tests for this and resolve once I’ve confirmed (or created) them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’ve drafted 8 tests here: https://github.com/meyerweb/wpt/tree/direction-3699/shadow-dom. They’re
lang-attribute-001.html
through-008.html
. They’re basically a mixture of host element, light tree element, and slot element with varyinglang
attribute values (if any) and CSS meant to highlight which elements match certain values.So: Am I testing the right things? If these are proper tests, I’ll generate reference renderings. If not, feel free to reach out via email or other channel to help me out. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for writing these tests. They generally look good to me. A few comments:
lang
attribute and matching/mismatching values. You might think about adding oneclosed
shadow root, just for completeness?dir
andlang
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, Mason! I’m a bit wary of conflating multiple tests in a single page, but I’ll investigate that and your polyfill.
What are your thoughts regard Ryosuke’s feedback on #3699 (#3699 (comment))?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! For non-visual tests, we often include many, many tests in a single file. So IMHO it’s ok/good to do here too.
I have to admit that I’m not sure I understand the nuance of the difference between the fantasai proposal and your text.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume we'll have tests (both for lang and dir) for slot elements which aren't in shadow DOM. Or which are first in shadow DOM but are then moved away from there to light DOM.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Edge case: this text doesn't work if the
slot
element is not inside a shadow root. (Do we have a test for that?)You'd want some language akin to "If the element is a slot element whose root is a shadow root and whose dir attribute is not ..." I think. And then below instead of talking about shadow root you just want to talk about its root. (As elements don't really have a shadow root, unless they're a shadow host, but then it means something different.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At least the test question here seems unresolved?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to run "find slottables" here to get these. Although maybe this should be "find flattened slottables"? I don't really understand how bidi-available can work here (except perhaps as an assert as assigned slot elements would necessarily be from another tree).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found a
<dfn>
of “find flattened slottables” in the source, but not “find slottables”. Does “Find flattened slottables, and then find among its slotted elements…” suffice?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure what that sentence means. Ideally we use concrete algorithms so it's unambiguous. Both of the algorithms I mentioned are defined in the DOM Standard.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I’ve addressed that in my latest push (made just now) in response to your feedback. Let me know!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you use flattened, how do you end up with slot elements? And how does bidi-available end up mattering here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fantasai and @tabatkins, maybe you can chime in here?
As for adding a reference, look for
dfn
elements withdata-x-href
attributes. That's where you can add additional references to other specifications. You probably want to place it next to the one for flattened.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’ve pushed a change changing this to “find slottables” and also including a new reference to finding slottables”
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd still like to see some kind of explanation. Also why one of these is used over the other.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@annevk I don't think I'm following the conversation here... From what I understand, slot elements exist in the flattened tree (but are
display: contents
by default, so they don't show up in the box tree by default). Wrt recursion, we don't need to recursively flatten the tree because once we hit a slot element, we return the directionality of that element; its content doesn't matter (except insofar as it influences the directionality of the slot element itself).The concept of bidi-available is in order to exclude the contents of e.g. script/style/textarea elements and any bidi-isolated elements, as these are things which are embedded within content and not representative of it such that we would want to extract directionality info from them.
Let me know if that answers your question; if not I need a bit more context in the question to understand what I'm being asked. ^_^
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, if you use "find flattened slotables" the slot elements are omitted (unless their root is not a shadow root). See https://dom.spec.whatwg.org/#find-flattened-slotables for its definition.
This is a purposely different algorithm from https://drafts.csswg.org/css-scoping/#flattening.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if the element is a slot element, but nothing is slotted to it - it has only the default content?
I guess I don't understand how one should read all the "If the..."
One says "If the element's dir attribute is in the auto state" and underneath it handles slot in a special way, but there is another "If the element is a slot element and the dir attribute is in the auto state"
How is
<slot dir=auto>
supposed to work?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@smaug---- I think a bunch of the lines below need to be deleted; added a comment to that effect. But to your point about the default content, I think a slot with dir=auto that has its default content instead of slotted content should be looking at its default content here. But I don't know how to express that in spec terminology.