lwc icon indicating copy to clipboard operation
lwc copied to clipboard

[Pivots] Support "extends" key in customElements.define()

Open nolanlawson opened this issue 1 year ago • 1 comments

Description

With custom element registry pivots (#2564), using the extends key is not supported:

customElements.define('my-button', Button, { extends: 'button' });

The above code will throw an error:

NotSupportedError: "extends" key in customElements.define() options is not supported

Note: Safari does not support this keyword (WebKit bug).

nolanlawson avatar Aug 04 '22 18:08 nolanlawson

Tricky parts about supporting this:

  1. Multiple elements with the same tag name probably can't extend different built-in elements – we only get one chance to call the real customElements.define()
  2. The standard pattern is to register class MyButton extends HTMLButtonElement {}, and in the polyfill we only patch the global window.HTMLElement. Do we need to patch all the other ones too? (HTMLButtonElement, HTMLLIElement, etc.)

nolanlawson avatar Aug 04 '22 19:08 nolanlawson

Pivots were dropped in #3310

nolanlawson avatar Jan 27 '23 00:01 nolanlawson

@rwaldron this is one of those things that we will never support. Probably we should document it somewhere in locker.

caridy avatar Jan 30 '23 14:01 caridy