Skip to content

Commit

Permalink
Bug 1633094 [wpt PR 23249] - Fix a null reference in declarative shad…
Browse files Browse the repository at this point in the history
…ow dom, a=testonly

Automatic update from web-platform-tests
Fix a null reference in declarative shadow dom

Previously, this would cause a null-reference:

  <template shadowroot=open>Content</template>

This is now fixed. In addition, this CL adds two more tests of
declarative shadow dom, for the two conditions listed at [1] and
[2]. The [2] condition test also tests this CL.

[1] https://github.com/mfreed7/declarative-shadow-dom/blob/master/README.md#root-element-is-template-shadowroot
[3] https://github.com/mfreed7/declarative-shadow-dom/blob/master/README.md#templates-containing-root-level-declarative-shadow-roots

Bug: 1042130
Change-Id: Id697fb3f89681981ca3ecc513451d0644430fd2b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2166357
Commit-Queue: Kouhei Ueno <kouheichromium.org>
Auto-Submit: Mason Freed <masonfreedchromium.org>
Reviewed-by: Kouhei Ueno <kouheichromium.org>
Cr-Commit-Position: refs/heads/master{#762842}

--

wpt-commits: 9b7ab1c11b7e0cf9b43ea6dbb282c33e4d193726
wpt-pr: 23249

UltraBlame original commit: 7dc0328ced91de6ffadcd49198c36da08b699891
  • Loading branch information
marco-c committed May 3, 2020
1 parent 3cd94c0 commit 807289c
Showing 1 changed file with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,16 @@
assert_true(!!host.shadowRoot,"No shadow root found");
assert_false(host.shadowRoot.delegatesFocus,"delegatesFocus should be false without the shadowrootdelegatesfocus attribute");
}, 'Declarative Shadow DOM: delegates focus attribute');

test(() => {
const host = document.createElement('div');
// Root element of innerHTML is a <template shadowroot>:
host.innerHTML = '<template shadowroot=open></template>';
assert_equals(host.shadowRoot, null, "Shadow root should not be present");
const tmpl = host.querySelector('template');
assert_true(!!tmpl,"Template should still be present");
assert_equals(tmpl.getAttribute('shadowroot'),"open","'shadowroot' attribute should still be present");
}, 'Declarative Shadow DOM: innerHTML root element');
</script>

<div id="multi-host">
Expand All @@ -123,7 +133,6 @@
<span>root 2</span>
</template>
</div>

<script>
test(() => {
const host = document.querySelector('#multi-host');
Expand All @@ -134,3 +143,19 @@
}, 'Declarative Shadow DOM: Multiple roots');

</script>

<template id="root-element-shadow">
<template shadowroot=open>Content</template>
</template>
<script>
test(() => {
// Root element of this template is a <template shadowroot>:
const template = document.querySelector('#root-element-shadow');
const host = document.createElement('div');
host.appendChild(template.content.cloneNode(true));
assert_equals(host.shadowRoot, null, "Shadow root should not be present");
const tmpl = host.querySelector('template');
assert_true(!!tmpl,"Template should still be present");
assert_equals(tmpl.getAttribute('shadowroot'),"open","'shadowroot' attribute should still be present");
}, 'Declarative Shadow DOM: template root element');
</script>

0 comments on commit 807289c

Please sign in to comment.