Skip to content

Commit

Permalink
bug #23982 [VarDumper] Strengthen dumped JS (nicolas-grekas)
Browse files Browse the repository at this point in the history
This PR was merged into the 2.7 branch.

Discussion
----------

[VarDumper] Strengthen dumped JS

| Q             | A
| ------------- | ---
| Branch?       | 2.7
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #23739
| License       | MIT
| Doc PR        | -

Commits
-------

5c1bd10 [VarDumper] Strengthen dumped JS
  • Loading branch information
fabpot committed Aug 26, 2017
2 parents b4452f8 + 5c1bd10 commit c896664
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php
Expand Up @@ -132,24 +132,24 @@ protected function getDumpHeader()
function toggle(a, recursive) {
var s = a.nextSibling || {}, oldClass = s.className, arrow, newClass;
if ('sf-dump-compact' == oldClass) {
if (/\bsf-dump-compact\b/.test(oldClass)) {
arrow = '▼';
newClass = 'sf-dump-expanded';
} else if ('sf-dump-expanded' == oldClass) {
} else if (/\bsf-dump-expanded\b/.test(oldClass)) {
arrow = '▶';
newClass = 'sf-dump-compact';
} else {
return false;
}
a.lastChild.innerHTML = arrow;
s.className = newClass;
s.className = s.className.replace(/\bsf-dump-(compact|expanded)\b/, newClass);
if (recursive) {
try {
a = s.querySelectorAll('.'+oldClass);
for (s = 0; s < a.length; ++s) {
if (a[s].className !== newClass) {
if (-1 == a[s].className.indexOf(newClass)) {
a[s].className = newClass;
a[s].previousSibling.lastChild.innerHTML = arrow;
}
Expand Down Expand Up @@ -205,7 +205,7 @@ function isCtrlKey(e) {
if (f && t && f[0] !== t[0]) {
r.innerHTML = r.innerHTML.replace(new RegExp('^'+f[0].replace(rxEsc, '\\$1'), 'mg'), t[0]);
}
if ('sf-dump-compact' == r.className) {
if (/\bsf-dump-compact\b/.test(r.className)) {
toggle(s, isCtrlKey(e));
}
}
Expand Down Expand Up @@ -255,10 +255,10 @@ function isCtrlKey(e) {
a.title = (a.title ? a.title+'\n[' : '[')+keyHint+'+click] Expand all children';
a.innerHTML += '<span>▼</span>';
a.className += ' sf-dump-toggle';
if ('sf-dump' != elt.parentNode.className) {
if (!/\bsf-dump\b/.test(elt.parentNode.className)) {
toggle(a);
}
} else if ("sf-dump-ref" == elt.className && (a = elt.getAttribute('href'))) {
} else if (/\bsf-dump-ref\b/.test(elt.className) && (a = elt.getAttribute('href'))) {
a = a.substr(1);
elt.className += ' '+a;
Expand Down

0 comments on commit c896664

Please sign in to comment.