Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit df20e80

Browse files
bug #27064 [VarDumper] Fix HtmlDumper classes match (ogizanagi)
This PR was merged into the 3.4 branch. Discussion ---------- [VarDumper] Fix HtmlDumper classes match | Q | A | ------------- | --- | Branch? | 3.4 <!-- see below --> | Bug fix? | yes | 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 and src/**/CHANGELOG.md files --> | Tests pass? | yes <!-- please add some, will be required by reviewers --> | Fixed tickets | #27045 <!-- #-prefixed issue number(s), if any --> | License | MIT | Doc PR | N/A Commits ------- 229430f [VarDumper] Fix HtmlDumper classes match
2 parents c2eeb29 + 229430f commit df20e80

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,9 @@ function xpathString(str) {
310310
311311
return "concat(" + parts.join(",") + ", '')";
312312
}
313+
function xpathHasClass(className) {
314+
return "contains(concat(' ', normalize-space(@class), ' '), ' " + className +" ')";
315+
}
313316
addEventListener(root, 'mouseover', function (e) {
314317
if ('' != refStyle.innerHTML) {
315318
refStyle.innerHTML = '';
@@ -516,7 +519,15 @@ function showCurrent(state)
516519
return;
517520
}
518521
519-
var xpathResult = doc.evaluate('//pre[@id="' + root.id + '"]//span[@class="sf-dump-str" or @class="sf-dump-key" or @class="sf-dump-public" or @class="sf-dump-protected" or @class="sf-dump-private"][contains(translate(child::text(), ' + xpathString(searchQuery.toUpperCase()) + ', ' + xpathString(searchQuery.toLowerCase()) + '), ' + xpathString(searchQuery.toLowerCase()) + ')]', document, null, XPathResult.ORDERED_NODE_ITERATOR_TYPE, null);
522+
var classMatches = [
523+
"sf-dump-str",
524+
"sf-dump-key",
525+
"sf-dump-public",
526+
"sf-dump-protected",
527+
"sf-dump-private",
528+
].map(xpathHasClass).join(' or ');
529+
530+
var xpathResult = doc.evaluate('.//span[' + classMatches + '][contains(translate(child::text(), ' + xpathString(searchQuery.toUpperCase()) + ', ' + xpathString(searchQuery.toLowerCase()) + '), ' + xpathString(searchQuery.toLowerCase()) + ')]', root, null, XPathResult.ORDERED_NODE_ITERATOR_TYPE, null);
520531
521532
while (node = xpathResult.iterateNext()) state.nodes.push(node);
522533

0 commit comments

Comments
 (0)