cramforce/splittable

Doesn't work with globals that closure is not aware of

matthewp opened this issue · 4 comments

class MyWidget extends HTMLElement {
  connectedCallback(){
    console.log("hello world");
  }
}

customElements.define('my-widget', MyWidget);

It's fine with the HTMLElement global but not customElements.

index.js:7: WARNING - Cannot access property define of non-object type undefined.
customElements.define('my-widget', MyWidget);
^

0 error(s), 1 warning(s), 97.0% typed

Sorry for all of the bug reports, will stop for now.

Should note that while there is only a warning above, it rewrites the code to replace customElements.define with customElements.a which doesn't exist on the global. Trying other variants like window.customElements.define and self.customElements.define doesn't help.

Thanks for the reports!

For now, you can use window['customElements']['define']

Ok, I promise this is the last one, related to this, #8

Closing as WAI.