Created attachment 462404 [details] Test In the attached test case, we should see: [object HTMLDivElement] bar null null Instead, we see: [object HTMLDivElement] bar null null That is, when the node assigned to element.ariaActiveDescendantElement has been moved to inside a shadow tree, getAttribute('aria-activedescendant') should return null.
<rdar://problem/100042078>
Expected: In the attached test case, we should see: [object HTMLDivElement] bar null null Actual: [object HTMLDivElement] bar null bar
There's a test case in the WPT test that checks this: https://github.com/web-platform-tests/wpt/blob/master/html/dom/aria-element-reflection.html#L231 The test moves an element to the Shadow DOM then checks that ariaActiveDescendantElement is null. Checking the spec (https://html.spec.whatwg.org/multipage/common-dom-interfaces.html#reflecting-content-attributes-in-idl-attributes) this is null because of this text: " 1. If element's explicitly set attr-element is not null: * If element's explicitly set attr-element is a descendant of any of element's shadow-including ancestors, then return element's explicitly set attr-element. * Otherwise, return null. " The first condition is not met, so it returns null. But the test case explicitly checks that the attribute is still kept with the original value. Should the fact that an element has been moved into a shadow tree has an effect on the attributes of another element? Is the test case right or wrong?
Hm... looks like the spec has setter steps like this. Which means that content attribute will have stale ID set. 1.If the given value is null, then: 1. Set this's explicitly set attr-element to null. 2. Remove the content attribute from this. 3. Return. 2. Let id be the empty string. 3. If the given value: * has the same root as this, and * has an id attribute, and *is the first element in this's node tree whose ID is the value of that id attribute, then set id to the given value's ID. 4. Set the content attribute's value for this to id. 5. Set this's explicitly set attr-element to a weak reference to the given value.
Filed https://github.com/whatwg/html/issues/8306
(In reply to Ryosuke Niwa from comment #5) > Filed https://github.com/whatwg/html/issues/8306 Update bug title after the discussion on that issue. Going back to the first example, the idea is that we won't reflect the content attribute and we'll just set the empty string there.
Committed 255267@main (05f04306d2dc): <https://commits.webkit.org/255267@main> Reviewed commits have been landed. Closing PR #4977 and removing active labels.