Skip to content

Commit 5b9fdd2

Browse files
Reduce common control flows
1 parent 058d78b commit 5b9fdd2

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

Form.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -421,16 +421,14 @@ private function initialize(): void
421421
$formId = Crawler::xpathLiteral($this->node->getAttribute('id'));
422422

423423
$fieldNodes = $xpath->query(\sprintf('( descendant::input[@form=%s] | descendant::button[@form=%1$s] | descendant::textarea[@form=%1$s] | descendant::select[@form=%1$s] | //form[@id=%1$s]//input[not(@form)] | //form[@id=%1$s]//button[not(@form)] | //form[@id=%1$s]//textarea[not(@form)] | //form[@id=%1$s]//select[not(@form)] )[( not(ancestor::template) or ancestor::turbo-stream )]', $formId));
424-
foreach ($fieldNodes as $node) {
425-
$this->addField($node);
426-
}
427424
} else {
428425
// do the xpath query with $this->node as the context node, to only find descendant elements
429426
// however, descendant elements with form attribute are not part of this form
430427
$fieldNodes = $xpath->query('( descendant::input[not(@form)] | descendant::button[not(@form)] | descendant::textarea[not(@form)] | descendant::select[not(@form)] )[( not(ancestor::template) or ancestor::turbo-stream )]', $this->node);
431-
foreach ($fieldNodes as $node) {
432-
$this->addField($node);
433-
}
428+
}
429+
430+
foreach ($fieldNodes as $node) {
431+
$this->addField($node);
434432
}
435433

436434
if ($this->baseHref && '' !== $this->node->getAttribute('action')) {

0 commit comments

Comments
 (0)