From 570ffde2db50a06da13bceb5afa5c0ec1ad6f41b Mon Sep 17 00:00:00 2001 From: Daniel Clark Date: Fri, 29 May 2026 13:49:57 -0700 Subject: [PATCH] [Reference Target] Reflect host even if reference target is invalid Currently if a shadow root's reference target doesn't match any ID in the shadow, any element-reflecting IDL attributes (e.g. popoverTargetElement) referring to the shadow host will return null. Recent thinking in [1] and the current state of the spec PR [2] is that these should still reflect the shadow host, same as if the reference target pointed to a matching element. Update the Chromium implementation and tests to match this updated behavior. As it turns out, this also slightly simplifies the implementation. [1] https://github.com/WICG/webcomponents/issues/1114 [2] https://github.com/whatwg/html/pull/10995 Bug: 346835896 Change-Id: Ic321d5dffc1800fc081e9edfbb46524acc63a8be Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7883837 Reviewed-by: Mason Freed Commit-Queue: Dan Clark Cr-Commit-Position: refs/heads/main@{#1638691} --- .../resources/property-reflection-helper.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/shadow-dom/reference-target/tentative/resources/property-reflection-helper.js b/shadow-dom/reference-target/tentative/resources/property-reflection-helper.js index 46daa4e10be1ed..a9494c629a97da 100644 --- a/shadow-dom/reference-target/tentative/resources/property-reflection-helper.js +++ b/shadow-dom/reference-target/tentative/resources/property-reflection-helper.js @@ -70,18 +70,18 @@ function test_idl_setter(element_creation_method, test_name_suffix, referencing_ if (expected_behavior === Behavior.ReflectsHost) { referencing_element[reflected_property] = host; - // For element reflecting properties, the IDL getter should return null when the explicitly - // set element has an invalid reference target. - assert_equals(referencing_element[reflected_property], null); + // For element reflecting properties, the IDL getter returns the element even + // if it has an invalid reference target. + assert_equals(referencing_element[reflected_property], host); } else if (expected_behavior === Behavior.ReflectsHostReadOnly) { referencing_element[reflected_property] = host; // Setting a read-only property has no effect. assert_equals(referencing_element[reflected_property], null); } else if (expected_behavior === Behavior.ReflectsHostInArray) { referencing_element[reflected_property] = [ host ]; - // For element reflecting properties, the IDL getter should not return explicitly set elements - // if they have an invalid reference target. - assert_array_equals(referencing_element[reflected_property], []); + // For element reflecting properties, the IDL getter returns the elements even if they have + // invalid reference targets. + assert_array_equals(referencing_element[reflected_property], [host]); } else if (expected_behavior === Behavior.IsNull) { referencing_element[reflected_property] = host; assert_equals(referencing_element[reflected_property], null);