[Webkit-unassigned] [Bug 183586] New: Custom Elements: connectedCallback is invoked at unexpected timing

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Mon Mar 12 19:28:53 PDT 2018


https://bugs.webkit.org/show_bug.cgi?id=183586

            Bug ID: 183586
           Summary: Custom Elements: connectedCallback is invoked at
                    unexpected timing
           Product: WebKit
           Version: Safari Technology Preview
          Hardware: Unspecified
                OS: Unspecified
            Status: NEW
          Severity: Normal
          Priority: P2
         Component: HTML DOM
          Assignee: webkit-unassigned at lists.webkit.org
          Reporter: tkent at chromium.org
                CC: cdumez at apple.com

Created attachment 335672

  --> https://bugs.webkit.org/attachment.cgi?id=335672&action=review

Repro

Load the following HTML:

<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);

document.body.innerHTML = '<x-parenter><x-child></x-child></x-parenter>';
</script>
</body>


Chrome and Firefox Nightly show nothing, Safari TP 50 shows "conenctedCallback called when not connected!"
It seems "this.removeChild(child);" in Parenter connectedCallback unexpectedly invokes x-child's reactions.


Originally reported to crbug.com: crbug.com/821195

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20180313/34c0ea82/attachment.html>


More information about the webkit-unassigned mailing list