Closed
Conversation
maelanleborgne
commented
Jun 19, 2025
Member
|
Hey @maelanleborgne! Sorry for the long delay on this. I didn't know about the form attribute! I am a bit confused though. |
Contributor
|
We use this a LOT in the work project, with form in main content, and submit buttons in an outer div. The button can be either in another form, or more generally not in the form at all (I may have another solution @maelanleborgne ) |
1905533 to
f57911d
Compare
Member
|
Thanks @maelanleborgne! I rebased, CI is green!
@smnandre I was going to merge this and release a 1.0.0, want me to hold off? |
Author
Member
|
Sounds good! |
Contributor
Member
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.
Closes zenstruck/browser#166
Pretty rough implementation of a feature that is central for our project tests, and that we currently circumvent by abusing reflection methods. It would be very nice to have this feature shipped in the library.
I'll let GPT describe the PR :
Description
This pull request refactors the
FormandElementclasses to improve handling of form elements, particularly those with explicitformattributes. It updates the logic for identifying a form associated with an element.Refactoring and Enhancements:
src/Dom/Node/Form.php: Added thefindNodesForFormmethod to refine how form-related nodes are identified. This method accounts for both direct descendants and nodes explicitly referencing the form via theformattribute. Updatedfields,buttons, andsubmitButtonsmethods to usefindNodesForFormfor improved accuracy.src/Dom/Node/Form/Element.php: Enhanced theformmethod to prioritize elements with explicitformattributes before falling back to the closestformancestor.Test Coverage:
tests/Node/FormTest.php: Added unit tests to validate the behavior of forms with and without IDs, ensuring correct identification of associated fields and buttons.