-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Should lang be propagated across shadow tree boundaries? #4906
Comments
Well, this is not so obvious. More complex test-case: <!doctype html>
<html lang="en">
<link rel="author" href="mailto:emilio@crisal.io" title="Emilio Cobos Álvarez">
<link rel="author" href="https://mozilla.org" title="Mozilla">
<link rel="help" href="https://html.spec.whatwg.org/#attr-lang">
<link rel="help" href="https://github.com/whatwg/html/issues/4906">
<link rel="match" href="lang-001-ref.html">
<style>
#host > div {
width: 100px;
height: 100px;
}
#host > div:lang(de) {
background-color: green;
}
#host > div:lang(en) {
background-color: red;
}
</style>
<div id="host"><div></div></div>
<script>
host.attachShadow({ mode: "open" }).innerHTML = `
<style>
div:lang(en) {
width: 100px;
height: 100px;
background-color: green;
}
</style>
<div></div>
<slot lang="de"></slot>
`;
</script>
</html> Seems like WebKit and Gecko follow the spec as-written (light DOM parent). Blink uses parent-or-host-node, that is, not going through slots. How do we want this to behave? cc @rniwa @domenic @smaug---- @annevk |
My initial thinking is: I would expect lang to use light DOM. And with host... It is a bit weird to propagate semantic information to the shadow DOM automatically when light DOM has no idea whether shadow DOM might use the same lang. If shadow DOM has need for some particular language, it should explicitly set it. But then, how to deal with text nodes under shadow root. Or perhaps one is just forced to use an extra element there in that case. One option is to add some flags to ShadowRoot init to have whatever behavior shadow dom author wants, but not sure we want to go that route. |
Yeah, I don't think lang should use the flat tree. In the light dom, it should use the visible relationships; that's the interface you're programming the Like smaug, I don't think it's reasonable to assume that the component author has a good idea of what lang will be shoved into its slots. |
Retitling, because I agree with y'all :) |
The one thing I care somewhat strongly about is that this behaves the same as |
Somewhat tricky issue here is what happens with "dir=auto". See #3699 (comment). Whatever we decide to do with |
@rniwa lang doesn't have an auto value, that is, it doesn't do any introspection of the element's own content. But I agree lang and dir should be consistent. |
@fantasai : Per today's F2F discussion, lang should also propagate into the shadow root but not into slot. Does that match your expectation / understanding? |
So we'd need to update
To something like
(Probably the whole section could do with a bit of a refactoring, but this is mostly to illustrate the normative change.) This can result in weird cases where the language of a text node is different from its composed/flat element parent (though never different from its (actual) element parent), but that's probably okay. Edit: for clarity, this is the behavior of Blink per @emilio above and what more or less had agreement already. |
See also #3821, #3699.
Testcase:
The text was updated successfully, but these errors were encountered: