Skip to content

Fix: avoid modifying element in Web Component constructor to comply w…#39

Open
telephant wants to merge 1 commit intoryansolid:masterfrom
telephant:fix/webcomponent-constructor-modification
Open

Fix: avoid modifying element in Web Component constructor to comply w…#39
telephant wants to merge 1 commit intoryansolid:masterfrom
telephant:fix/webcomponent-constructor-modification

Conversation

@telephant
Copy link
Copy Markdown

According to the Web Components specification, the constructor of a custom element must not modify the element — for example, by adding attributes, child elements, or own properties that trigger internal checks.

Fix

  • Remove property initialization that modifies the element during construction.
  • Defer any element modifications to connectedCallback or another safe lifecycle phase.

Result

This change ensures the custom element conforms to the Web Components spec and avoids NotSupportedError in browsers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant