Netflix / x-element

A dead simple starting point for custom elements.
Apache License 2.0
28 stars 12 forks source link

Internal props should not participate in pre-upgrade element initialization. #129

Closed theengineear closed 1 year ago

theengineear commented 1 year ago

The point of the internal properties are to specifically not participate in the public element interface. I.e., element.title should have nothing to do with element.internal.title. This is usually benign, but can cause problems if the related public property has restrictions on how it’s meant to be used. For example, the following will fail if you register it and try to print it in the DOM:

class InternalExample extends XElement {
  static get properties() {
    return { children: { internal: true } }; // The "children" property is _read only_ on the public interface.
  }
}
// TypeError: Cannot set property children of #<Element> which has only a getter

Proposal

Simply don’t perform a lookup on the public interface for internal properties. This is the intended behavior, but there’s just no guard yet.