Repository navigation
Move isValidEvent into Form and FieldsetElement and add ON_ASSEMBLED support - #207
Merged
Merged
Conversation
…Element` The trait's shared list included form lifecycle events (`ON_SUBMIT`, `ON_SENT`, `ON_ERROR`, `ON_REQUEST`, `ON_VALIDATE`) that `FieldsetElement` never emits. Keeping a single list in the trait forced `FieldsetElement` to accept events it has no way of dispatching. By moving the check into each class, the allowed set can be scoped correctly per class. `FieldsetElement` is restricted to `ON_ELEMENT_REGISTERED`, the only form-elements event it actually emits.
`Form::ON_ELEMENT_REGISTERED` coupled the trait to `Form` specifically, even though the trait is also used by `FieldsetElement`. Using `static::` resolves the constant through the using class, consistent with how `HtmlDocument` emits `ON_ASSEMBLED`.
jrauh01
force-pushed
the
form-elements-on-assembled-event
branch
from
July 30, 2026 08:46
3b02120 to
1c7824e
Compare
Contributor
Author
|
No it doesn't, there's still a |
Member
It's fine. Let's keep it as is. |
lippserd
approved these changes
Jul 30, 2026
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.
FormandFieldsetElementpreviously rejectedON_ASSEMBLEDas an invalid event, causingon(HtmlDocument::ON_ASSEMBLED, ...)to throw anInvalidArgumentExceptionon both classes. This movesisValidEventout of theFormElementstrait and into each concrete class so the allowed set can be scoped correctly per class.Formaccepts the full set of form lifecycle events plusON_ASSEMBLED.FieldsetElementis restricted toON_ELEMENT_REGISTEREDandON_ASSEMBLED, the only two events it actually emits. Previously the shared trait list causedFieldsetElementto accept events it never dispatches:ON_SUBMIT,ON_SENT,ON_ERROR,ON_REQUEST, andON_VALIDATE. Registering listeners for those events would silently do nothing. They now correctly throw. This is a breaking change for any code that registered such listeners on aFieldsetElement.Any future class that uses the
FormElementstrait without providing its ownisValidEventoverride will fall through toEvents::isValidEvent, which accepts all event names unconditionally. That class must provide its own override to enforce a meaningful restriction.