10000 minor #26490 [DomCrawler] Improve the sprintf() call in selectButton(… · src-run/symfony@e317879 · GitHub
[go: up one dir, main page]

Skip to content

Commit e317879

Browse files
minor symfony#26490 [DomCrawler] Improve the sprintf() call in selectButton() (dunglas)
This PR was squashed before being merged into the 4.1-dev branch (closes symfony#26490). Discussion ---------- [DomCrawler] Improve the sprintf() call in selectButton() | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? |no <!-- don't forget to update src/**/CHANGELOG.md files --> | BC breaks? | no <!-- see https://symfony.com/bc --> | Deprecations? |no <!-- don't forget to update UPGRADE-*.md files --> | Tests pass? | yes <!-- please add some, will be required by reviewers --> | Fixed tickets | n/a <!-- #-prefixed issue number(s), if any --> | License | MIT | Doc PR | n/a Code cleanup and minor performance improvement. Similar to symfony#26485. Commits ------- a00cce6 [DomCrawler] Improve the sprintf() call in selectButton()
2 parents cab05ab + a00cce6 commit e317879

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

src/Symfony/Component/DomCrawler/Crawler.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -738,12 +738,9 @@ public function selectImage($value)
738738
*/
739739
public function selectButton($value)
740740
{
741-
$translate = 'translate(@type, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "abcdefghijklmnopqrstuvwxyz")';
742-
$xpath = sprintf('descendant-or-self::input[((contains(%s, "submit") or contains(%1$s, "button")) and contains(concat(\' \', normalize-space(string(@value)), \' \'), %s)) ', $translate, static::xpathLiteral(' '.$value.' ')).
743-
sprintf('or (contains(%s, "image") and contains(concat(\' \', normalize-space(string(@alt)), \' \'), %s)) or @id=%s or @name=%s] ', $translate, static::xpathLiteral(' '.$value.' '), static::xpathLiteral($value), static::xpathLiteral($value)).
744-
sprintf('| descendant-or-self::button[contains(concat(\' \', normalize-space(string(.)), \' \'), %s) or @id=%s or @name=%s]', static::xpathLiteral(' '.$value.' '), static::xpathLiteral($value), static::xpathLiteral($value));
745-
746-
return $this->filterRelativeXPath($xpath);
741+
return $this->filterRelativeXPath(
742+
sprintf('descendant-or-self::input[((contains(%1$s, "submit") or contains(%1$s, "button")) and contains(concat(\' \', normalize-space(string(@value)), \' \'), %2$s)) or (contains(%1$s, "image") and contains(concat(\' \', normalize-space(string(@alt)), \' \'), %2$s)) or @id=%3$s or @name=%3$s] | descendant-or-self::button[contains(concat(\' \', normalize-space(string(.)), \' \'), %2$s) or @id=%3$s or @name=%3$s]', 'translate(@type, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "abcdefghijklmnopqrstuvwxyz")', static::xpathLiteral(' '.$value.' '), static::xpathLiteral($value))
743+
);
747744
}
748745

749746
/**

0 commit comments

Comments
 (0)
0