-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[DomCrawler] fixed HTML5 form attribute handling #8197
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
$fieldNodes = $xpath->query('descendant::input | descendant::button | descendant::textarea | descendant::select', $root); | ||
foreach ($fieldNodes as $node) { | ||
// if the descendant element has an HTML5 form attribute, it should match the parent form id | ||
if (!$node->hasAttribute('form') || ($this->node->hasAttribute('id') && $this->node->getAttribute('id') == $node->getAttribute('form'))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$this->node->hasAttribute('id')
will always be false here as you are in the else
part.
$node = $document->importNode($this->node->ownerDocument->documentElement, true); | ||
$root->appendChild($node); | ||
$formNode = $xpath->query(sprintf("//form[@id=%s]", Crawler::xpathLiteral($this->node->getAttribute('id'))))->item(0); | ||
$fieldNodes = $xpath->query('descendant::input | descendant::button | descendant::textarea | descendant::select', $root); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you are now querying all input elements in the page. Is it really more efficient than the previous code ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope. I tried Firefox and it preserved form element order, so I wanted to implement the same way but I am not sure if it really matters. I can change it to a more efficient one if we decide order does not need to be preserved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is the order of POST params really relevant ?
@fabpot anything missing in this PR ? |
This PR was squashed before being merged into the 2.3 branch (closes #8197). Discussion ---------- [DomCrawler] fixed HTML5 form attribute handling Fixed HTML5 form attribute handling and improved a test case to test more thoroughly | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #6239 | License | MIT | Doc PR | no Commits ------- 04e730e [DomCrawler] fixed HTML5 form attribute handling
Fixed HTML5 form attribute handling and improved a test case to test more thoroughly