This repository was archived by the owner on Oct 26, 2021. It is now read-only.
Description Custom elements inserted via insertAdjacentHTML are ignored / never upgraded.
Diff with failing tests
diff --git a/tests/html/Element/index.html b/tests/html/Element/index.html
index b771d37..872b872 100644
--- a/tests/html/Element/index.html
+++ b/tests/html/Element/index.html
@@ -9,5 +9,6 @@
'./removeAttribute.html',
'./removeAttributeNS.html',
'./insertAdjacentElement.html',
+ './insertAdjacentHTML.html'
]);
</script>
diff --git a/tests/html/Element/insertAdjacentHTML.html b/tests/html/Element/insertAdjacentHTML.html
new file mode 100644
index 0000000..8dca1e6
--- /dev/null
+++ b/tests/html/Element/insertAdjacentHTML.html
@@ -0,0 +1,72 @@
+ <!doctype html>
+ <html>
+ <head>
+ <title>Element#insertAdjacentHTML</title>
+ <script>
+ (window.customElements = window.customElements || {}).forcePolyfill = true;
+ </script>
+ <script src="../../../../es6-promise/dist/es6-promise.auto.min.js"></script>
+ <script src="../../../../web-component-tester/browser.js"></script>
+ <script src="../../../custom-elements.min.js"></script>
+ </head>
+ <body>
+ <script>
+ function generateLocalName() {
+ return 'test-element-' + Math.random().toString(32).substring(2);
+ }
+
+ function defineWithLocalName(localName, observedAttributes) {
+ customElements.define(localName, class extends HTMLElement {
+ constructor() {
+ super();
+ this.constructed = true;
+ this.connectedCallbackCount = 0;
+ this.disconnectedCallbackCount = 0;
+ }
+
+ connectedCallback() {
+ this.connectedCallbackCount++;
+ }
+
+ disconnectedCallback() {
+ this.disconnectedCallbackCount++;
+ }
+ });
+ }
+
+ suite('Custom elements in HTML strings are created using `insertAdjacentHTML`.', function() {
+ let localName;
+
+ setup(function() {
+ localName = generateLocalName();
+ defineWithLocalName(localName);
+ });
+
+ test('Disconnected context', function() {
+ const div = document.createElement('div');
+ div.insertAdjacentHTML('beforeend', `<${localName}></${localName}>`);
+
+ assert.equal(div.childNodes.length, 1);
+ assert.equal(div.childNodes[0].localName, localName);
+ assert.equal(div.childNodes[0].constructed, true);
+ assert.equal(div.childNodes[0].connectedCallbackCount, 0);
+ assert.equal(div.childNodes[0].disconnectedCallbackCount, 0);
+ });
+
+ test('Connected context', function() {
+ const div = document.createElement('div');
+ document.body.appendChild(div);
+ div.insertAdjacentHTML('beforeend', `<${localName}></${localName}>`);
+
+ assert.equal(div.childNodes.length, 1);
+ assert.equal(div.childNodes[0].localName, localName);
+ assert.equal(div.childNodes[0].constructed, true);
+ assert.equal(div.childNodes[0].connectedCallbackCount, 1);
+ assert.equal(div.childNodes[0].disconnectedCallbackCount, 0);
+
+ document.body.removeChild(div);
+ });
+ });
+ </script>
+ </body>
+ </html>
Resulting failures
Reactions are currently unavailable
Custom elements inserted via
insertAdjacentHTMLare ignored / never upgraded.Diff with failing tests
Resulting failures