Skip to content

Commit

Permalink
Add <template>'s shadowRootDelegatesFocus & shadowRootClonable
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=271640

Reviewed by Tim Nguyen.

These were missed in prior PRs that added support for the corresponding
content attributes.

Partially synchronize WPT up to the following commit to add missing
test coverage:
web-platform-tests/wpt@2969dd3

* LayoutTests/imported/w3c/web-platform-tests/shadow-dom/declarative/declarative-shadow-dom-basic-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/shadow-dom/declarative/declarative-shadow-dom-basic.html:
* Source/WebCore/html/HTMLTemplateElement.idl:

Canonical link: https://commits.webkit.org/276631@main
  • Loading branch information
annevk committed Mar 25, 2024
1 parent 2fa5e50 commit db0669a
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ PASS Declarative Shadow DOM: Basic test
PASS Declarative Shadow DOM: Feature detection
PASS Shadowrootmode reflection
PASS Shadowrootmode reflection, setter
PASS Shadowrootdelegatesfocus reflection
PASS Shadowrootdelegatesfocus reflection, setter
PASS Shadowrootclonable reflection
PASS Shadowrootclonable reflection, setter
PASS Declarative Shadow DOM: Fragment parser basic test
PASS Declarative Shadow DOM: Invalid shadow root attribute
PASS Declarative Shadow DOM: Closed shadow root attribute
Expand Down
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
3 changes: 3 additions & 0 deletions Source/WebCore/html/HTMLTemplateElement.idl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2012, Google Inc. All rights reserved.
* Copyright (c) 2017-2024 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
Expand Down Expand Up @@ -34,4 +35,6 @@
] interface HTMLTemplateElement : HTMLElement {
readonly attribute DocumentFragment content;
[CEReactions=NotNeeded] attribute [AtomString] DOMString shadowRootMode;
[CEReactions=NotNeeded, Reflect=shadowrootdelegatesfocus] attribute boolean shadowRootDelegatesFocus;
[CEReactions=NotNeeded, Reflect=shadowrootclonable] attribute boolean shadowRootClonable;
};

0 comments on commit db0669a

Please sign in to comment.