Repository navigation
Conversation
A form ignores a custom element inside it unless the element's class has static formAssociated = true. Without it, attachInternals() still succeeds but the internals have no form: reading .form throws NotSupportedError. There was no way to say it from LitElement.init, so a custom submit button or input meant copying the whole LitElement attribute to add one getter. config.formAssociated <- true defines that static getter on the class, next to the ones already defined for properties and styles. Two tests: the flag reaches the element definition only for an element that asked for it, and a submit button that isn't a <button> submits the form it is in. With the getter removed, both fail. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
config.formAssociatedtoLitElement.init, so a[<LitElement>]can take part in the form it's inside.Why
A form ignores a custom element unless the element's class has
static formAssociated = true. Without it,attachInternals()still succeeds, but the internals have no form. Reading.formthrows:Until now there was no way to set it from
LitElement.init, so writing a custom input or submit button meant copying the wholeLitElementattribute just to add one static getter.What changes
LitConfig.formAssociated(defaultfalse), with a doc comment.LitElementAttribute: when it's set, defines a staticformAssociatedgetter on the class, next to the getters it already defines forpropertiesandstyles. Nothing changes for elements that don't set it.docsrc/docs/web-components.md.Tests
test/FormElementTest.fs, two tests:<button>submits the<form>it sits in.With the getter removed, both fail (the second with the
NotSupportedErrorabove).dotnet build Fable.Lit.slnandnpm testpass (39 tests).🤖 Generated with Claude Code