x-tag / core

The Heart of X-Tag
http://x-tag.github.io/
Other
1.25k stars 151 forks source link

Migration guide || equivalents of inserted/...? #206

Open Janiczek opened 4 years ago

Janiczek commented 4 years ago

Hello! We're being nudged by Chrome warnings to stop using 1.5.11 and go for something newer:

[Deprecation] document.registerElement is deprecated and will be removed in M73, around March 2019. Please use window.customElements.define instead. See https://www.chromestatus.com/features/4642138092470272 for more details.

When trying to migrate our v1 components to v2, we hit a roadblock: how to represent the inserted and removed lifecycle hooks? They don't seem to have support in v2. (Whatever answer will this have, it would be nice to write it in the actual docs.)

janjelinek commented 4 years ago

For future Us: X-tag v2 is using native callbacks for WebComponents it means you can simply do something like

xtag.create('x-frank', class extends XTagElement {
  connectedCallback() { 
    //replacemend for inserted hook
  }
  disconnectedCallback() {
    //replacement for removed hook
  }
});

It's not much clear from X-tag V2 docs.