8000 [DomCrawler] fixed HTML5 form attribute handling by kepten · Pull Request #8197 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[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

Closed
wants to merge 3 commits into from

Conversation

kepten
Copy link
Contributor
@kepten kepten commented Jun 4, 2013

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

$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'))) {
Copy link
Member

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);
Copy link
Member

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 ?

Copy link
Contributor Author

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.

Copy link
Member

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 ?

@stof
Copy link
Member
stof commented Sep 17, 2013

@fabpot anything missing in this PR ?

fabpot added a commit that referenced this pull request Sep 17, 2013
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
@fabpot fabpot closed this Sep 17, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0