WebKit Bugzilla
Attachment 345834 Details for
Bug 183586
: connectedCallback is invoked during the removal of the element inside another element's connectedCallback
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
Another repro case
b.html (text/html), 1.32 KB, created by
Frédéric Wang (:fredw)
on 2018-07-26 01:05:22 PDT
(
hide
)
Description:
Another repro case
Filename:
MIME Type:
Creator:
Frédéric Wang (:fredw)
Created:
2018-07-26 01:05:22 PDT
Size:
1.32 KB
patch
obsolete
><!doctype html> ><html> ><head> ><title>connectedCallback when isConnected=false</title> ><style> >h1 { > color: red; >} ></style> ></head> ><body> ><script type="application/javascript"> >class Parenter extends HTMLElement { > connectedCallback() { > console.group('Parenter.connectedCallback'); > const child = this.firstChild; > this.removeChild(child); > console.groupEnd('Parenter.connectedCallback'); > > this.appendChild(child); > } >} >customElements.define('x-parenter', Parenter); > >class Child extends HTMLElement { > connectedCallback() { > const connected = this.isConnected; > console.log('x-child connected '+connected); > > if (!connected) { > const h1 = document.createElement('h1'); > h1.textContent = 'connectedCallback called when not connected!'; > document.body.appendChild(h1) > } > } >} >customElements.define('x-child', Child); > >const htmlFragment = '<x-parenter><x-child></x-child></x-parenter>'; > >function appendWithDOMParser(body, fragment, mime) { > const doc = (new DOMParser()).parseFromString(fragment, mime); > const resultBody = document.importNode(doc.body, true); > body.appendChild(resultBody); >} > >// document.body.innerHTML = htmlFragment; >// document.body.insertAdjacentHTML('beforeend', htmlFragment); >appendWithDOMParser(document.body, htmlFragment, 'text/html'); > ></script> ></body> ></html>
<!doctype html> <html> <head> <title>connectedCallback when isConnected=false</title> <style> h1 { color: red; } </style> </head> <body> <script type="application/javascript"> class Parenter extends HTMLElement { connectedCallback() { console.group('Parenter.connectedCallback'); const child = this.firstChild; this.removeChild(child); console.groupEnd('Parenter.connectedCallback'); this.appendChild(child); } } customElements.define('x-parenter', Parenter); class Child extends HTMLElement { connectedCallback() { const connected = this.isConnected; console.log('x-child connected '+connected); if (!connected) { const h1 = document.createElement('h1'); h1.textContent = 'connectedCallback called when not connected!'; document.body.appendChild(h1) } } } customElements.define('x-child', Child); const htmlFragment = '<x-parenter><x-child></x-child></x-parenter>'; function appendWithDOMParser(body, fragment, mime) { const doc = (new DOMParser()).parseFromString(fragment, mime); const resultBody = document.importNode(doc.body, true); body.appendChild(resultBody); } // document.body.innerHTML = htmlFragment; // document.body.insertAdjacentHTML('beforeend', htmlFragment); appendWithDOMParser(document.body, htmlFragment, 'text/html'); </script> </body> </html>
View Attachment As Raw
Actions:
View
Attachments on
bug 183586
:
335672
|
340977
|
340981
|
341004
|
341117
|
341135
|
341186
|
341211
|
341272
|
341278
|
345570
|
345834
|
346614
|
347145
|
357032