Bug 245299 - Set empty string for reflection of IDREF attributes
Summary: Set empty string for reflection of IDREF attributes
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Accessibility (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks: 245301
  Show dependency treegraph
 
Reported: 2022-09-16 14:02 PDT by Ryosuke Niwa
Modified: 2022-10-07 06:56 PDT (History)
3 users (show)

See Also:


Attachments
Test (476 bytes, text/html)
2022-09-16 14:02 PDT, Ryosuke Niwa
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ryosuke Niwa 2022-09-16 14:02:48 PDT
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.
Comment 1 Radar WebKit Bug Importer 2022-09-16 14:03:05 PDT
<rdar://problem/100042078>
Comment 2 Ryosuke Niwa 2022-09-16 14:04:09 PDT
Expected:
In the attached test case, we should see:
[object HTMLDivElement]
bar
null
null

Actual:
[object HTMLDivElement]
bar
null
bar
Comment 3 Manuel Rego Casasnovas 2022-09-21 00:20:44 PDT
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?
Comment 4 Ryosuke Niwa 2022-09-21 23:14:32 PDT
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.
Comment 5 Ryosuke Niwa 2022-09-21 23:26:06 PDT
Filed https://github.com/whatwg/html/issues/8306
Comment 6 Manuel Rego Casasnovas 2022-10-04 03:53:36 PDT
(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.
Comment 7 EWS 2022-10-07 06:56:28 PDT
Committed 255267@main (05f04306d2dc): <https://commits.webkit.org/255267@main>

Reviewed commits have been landed. Closing PR #4977 and removing active labels.