-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix connectedCallback with document fragments
- Loading branch information
1 parent
79ff734
commit 15cbed6
Showing
2 changed files
with
34 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
test/web-platform-tests/to-upstream/custom-elements/connected-callbacks-template.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<!DOCTYPE html> | ||
<meta charset="utf-8"> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<!-- Regression test for https://github.com/jsdom/jsdom/issues/3290 --> | ||
|
||
<body> | ||
<script> | ||
"use strict"; | ||
|
||
test(() => { | ||
let innerConnectedCallbackCalled = false; | ||
customElements.define("inner-element", class extends HTMLElement { | ||
connectedCallback() { | ||
innerConnectedCallbackCalled = true; | ||
} | ||
}); | ||
|
||
let outerConnectedCallbackCalled = false; | ||
customElements.define("outer-element", class extends HTMLElement { | ||
connectedCallback() { | ||
const template = document.createElement("template"); | ||
template.innerHTML = "<inner-element></inner-element>"; | ||
this.appendChild(document.importNode(template.content, true)); | ||
outerConnectedCallbackCalled = true; | ||
} | ||
}); | ||
|
||
document.body.appendChild(document.createElement("outer-element")); | ||
assert_true(innerConnectedCallbackCalled, "inner connectedCallback must be called"); | ||
assert_true(outerConnectedCallbackCalled, "outer connectedCallback must be called"); | ||
}, "Nested custom element connectedCallback insertion involving a template DocumentFragment"); | ||
</script> |