Open Bug 1928667 Opened 4 days ago Updated 4 days ago

lang does not pierce shadow boundary

Categories

(Core :: CSS Parsing and Computation, defect)

Firefox 132
defect

Tracking

()

UNCONFIRMED

People

(Reporter: peter.rushforth, Unassigned)

Details

Attachments

(1 file)

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36

Steps to reproduce:

<!doctype html>
<html lang="de">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>localization.html</title>
</head>
<body >
<host-element lang="fr">
<template shadowrootmode="open">
<div>
<!-- should be in fr $0.closest(':lang(fr)') should be div -->
</div>
</template>
</host-element>
<script>
console.log(document.querySelector('host-element').shadowRoot.querySelector('div').closest(':lang(fr)'));
// in chrome 130: <div>...</div>
// in ff 132.0: null
</script>
</body>
</html>

Actual results:

In chrome 130, lang appears to correctly? pierce the shadow boundary, however in ff 132.0, it does not. See test case provided

Expected results:

I think it should apply to shadow content, as the mdn docs say this, but it appears fuzzy to me in the html spec.

https://developer.mozilla.org/en-US/docs/Web/API/Web_components/Using_shadow_DOM#attribute_inheritance

The Bugbug bot thinks this bug should belong to the 'Core::DOM: Core & HTML' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.

Component: Untriaged → DOM: Core & HTML
Product: Firefox → Core

The spec is a bit broken I think, when it comes to slot elements, but other than that there is some reasonable text in https://html.spec.whatwg.org/#the-lang-and-xml:lang-attributes

The inheritance is mostly a style engine feature, I think
https://searchfox.org/mozilla-central/rev/0d0eef18ea91e38ddfb82a1ac5d6560a146da5c0/servo/components/style/invalidation/element/element_wrapper.rs#147-160

Component: DOM: Core & HTML → CSS Parsing and Computation

In the spec, below here: https://html.spec.whatwg.org/#the-lang-and-xml:lang-attributes there's a list of steps, and the third step appears to cover the test case

"To determine the language of a node, user agents must use the first appropriate step in the following list:"

...

If the node's parent is a shadow root
Use the language of that shadow root's host.

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: