stencil icon indicating copy to clipboard operation
stencil copied to clipboard

fix(compiler): fix attachInternals should be usable without formAssoc…

Open pfteter opened this issue 8 months ago • 1 comments

Ticket: #6285

Stencil Version

4.33

Current Behavior

@AttachInternals() internals!: ElementInternals;

cannot be used without formAssociated: true in the metadata.

because of a condition in the compiler

Expected Behavior

@AttachInternals() internals!: ElementInternals;

should work without formAssociated: true in the metadata.

CustomStateSet can now be used without formAssociated for components that are not formAssociated.

Improvement: Add stencil support for custom state.

System Info


Steps to Reproduce

add

@AttachInternals() internals!: ElementInternals;

to a component, an console error will be shown

Code Reproduction URL

Additional Information

Will commit a fix for it, the solution is quite easy: https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/attachInternals

Does this introduce a breaking change?

  • [ ] Yes
  • [X] No

Testing

Manual testing / changing code in node_modules

pfteter avatar Jun 10 '25 12:06 pfteter

Also could we update the docs as they should be clarify that element internals can be used without form association.

christian-bromann avatar Jun 11 '25 17:06 christian-bromann

@pfteter mind running npm run prettier and check in the changes?

christian-bromann avatar Jun 25 '25 01:06 christian-bromann