DEV Community

Discussion on: Building Web Components with Vanilla JavaScript

Collapse
 
aspittel profile image
Ali Spittel

Awesome! Polymer is the best way to create web components that are cross-browser compatible. The API is somewhat different, but they are much more usable!

connectedCallback is called when the custom element is first connected to the document's DOM (according to the MDN documentation). So the container mounts to the DOM, then connectedCallback is triggered.

Collapse
 
jochemstoel profile image
Jochem Stoel • Edited

WebReflection on GitHub has a cross browser compatible polyfill of document.registerElement

Collapse
 
smalluban profile image
Dominik Lubański

connectedCallback is called every time, when an element is attached to document, so also when you move an element from one parent to another. MDN definition:

connectedCallback: Invoked each time the custom element is appended into a document-connected element. This will happen each time the node is moved, and may happen before the element's contents have been fully parsed.

(developer.mozilla.org/en-US/docs/W...)