Skip to content

Commit 47b9e9a

Browse files
committed
bug symfony#24747 [VarDumper] HtmlDumper: fix collapsing nodes with depth < maxDepth (ogizanagi)
This PR was merged into the 3.4 branch. Discussion ---------- [VarDumper] HtmlDumper: fix collapsing nodes with depth < maxDepth | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no <!-- don't forget to update src/**/CHANGELOG.md files --> | BC breaks? | no | Deprecations? | no <!-- don't forget to update UPGRADE-*.md files --> | Tests pass? | yes (failures unrelated) | Fixed tickets | N/A <!-- #-prefixed issue number(s), if any --> | License | MIT | Doc PR | N/A This error happens since symfony#23967: > (index):3 Uncaught TypeError: Cannot read property 'substr' of null https://github.com/symfony/symfony/blob/98dae3edb1ba8fa35c06a8c9a459e0ffb9105826/src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php#L325 when trying to collapse the root node (or more precisely, the nodes with a depth <= maxDepth) because it misses one of the `sf-dump-expanded`/`sf-dump-compact` classes which are necessary for the toggling to work. Commits ------- a1863c3 [VarDumper] HtmlDumper: fix collapsing nodes with depth <= maxDepth
2 parents ffc9884 + a1863c3 commit 47b9e9a

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -383,8 +383,9 @@ function xpathString(str) {
383383
x += elt.parentNode.getAttribute('data-depth')/1;
384384
}
385385
elt.setAttribute('data-depth', x);
386-
if (elt.className ? 'sf-dump-expanded' !== elt.className : (x > options.maxDepth)) {
387-
elt.className = 'sf-dump-expanded';
386+
var className = elt.className;
387+
elt.className = 'sf-dump-expanded';
388+
if (className ? 'sf-dump-expanded' !== className : (x > options.maxDepth)) {
388389
toggle(a);
389390
}
390391
} else if (/\bsf-dump-ref\b/.test(elt.className) && (a = elt.getAttribute('href'))) {

0 commit comments

Comments
 (0)