Skip to content

Commit

Permalink
Add shadowRootDelegatesFocus and shadowRootClonable reflection
Browse files Browse the repository at this point in the history
The `shadowRootDelegatesFocus` IDL is standardized [1], and was just
never added to Chromium. This CL lands this addition behind a kill
switch, but should be very safe to add.

The `shadowRootClonable` IDL is being added as part of [2], which
has support and should land soon.

[1] https://html.spec.whatwg.org/multipage/scripting.html#htmltemplateelement
[2] whatwg/html#10117

Bug: 1510466
Change-Id: I708ec8d562fa4d0fc59c73a071dbb191e1bd276e
  • Loading branch information
mfreed7 authored and chromium-wpt-export-bot committed Feb 13, 2024
1 parent f664d06 commit bb91a44
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions shadow-dom/declarative/declarative-shadow-dom-basic.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,49 @@
t.getAttribute('shadowrootmode', 'CLOSED');
}, 'Shadowrootmode reflection, setter');

test(() => {
const t = document.createElement('template');
t.setAttribute('shadowrootdelegatesfocus','');
assert_equals(t.shadowRootDelegatesFocus,true,'The shadowRootDelegatesFocus IDL should reflect the content attribute');
t.setAttribute('shadowrootdelegatesfocus','foobar');
assert_equals(t.shadowRootDelegatesFocus,true,'The value doesn\'t matter');
t.removeAttribute('shadowrootdelegatesfocus');
assert_equals(t.shadowRootDelegatesFocus,false,'No shadowRootDelegatesFocus attribute maps to false');
}, 'Shadowrootdelegatesfocus reflection');

test(() => {
const t = document.createElement('template');
assert_equals(t.getAttribute('shadowrootdelegatesfocus'), null);
t.shadowRootDelegatesFocus = true;
assert_equals(t.getAttribute('shadowrootdelegatesfocus'), '');
assert_equals(t.shadowRootDelegatesFocus, true);
t.shadowRootDelegatesFocus = false;
assert_equals(t.getAttribute('shadowrootdelegatesfocus'), null);
assert_equals(t.shadowRootDelegatesFocus, false);
}, 'Shadowrootdelegatesfocus reflection, setter');


test(() => {
const t = document.createElement('template');
t.setAttribute('shadowrootclonable','');
assert_equals(t.shadowRootClonable,true,'The shadowRootClonable IDL should reflect the content attribute');
t.setAttribute('shadowrootclonable','foobar');
assert_equals(t.shadowRootClonable,true,'The value doesn\'t matter');
t.removeAttribute('shadowrootclonable');
assert_equals(t.shadowRootClonable,false,'No shadowRootClonable attribute maps to false');
}, 'Shadowrootclonable reflection');

test(() => {
const t = document.createElement('template');
assert_equals(t.getAttribute('shadowrootclonable'), null);
t.shadowRootClonable = true;
assert_equals(t.getAttribute('shadowrootclonable'), '');
assert_equals(t.shadowRootClonable, true);
t.shadowRootClonable = false;
assert_equals(t.getAttribute('shadowrootclonable'), null);
assert_equals(t.shadowRootClonable, false);
}, 'Shadowrootclonable reflection, setter');

test(() => {
const div = document.createElement('div');
div.setHTMLUnsafe(`
Expand Down

0 comments on commit bb91a44

Please sign in to comment.