Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 9b841d9

Browse filesBrowse files
committed
bug #27189 [Profiler] Fix dump makes toolbar disappear (ogizanagi)
This PR was merged into the 4.1 branch. Discussion ---------- [Profiler] Fix dump makes toolbar disappear | Q | A | ------------- | --- | Branch? | 4.1 <!-- 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 | #27180 <!-- #-prefixed issue number(s), if any --> | License | MIT | Doc PR | N/A Don't know if there is a better solution than executing eval on the global scope. For ref: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval > If you use the eval function indirectly, by invoking it via a reference other than eval, as of ECMAScript 5 it works in the global scope rather than the local scope. This means, for instance, that function declarations create global functions, and that the code being evaluated doesn't have access to local variables within the scope where it's being called. Commits ------- 0cd51ae [Profiler] Fix dump makes toolbar disappear
2 parents 796c8fe + 0cd51ae commit 9b841d9
Copy full SHA for 9b841d9

File tree

1 file changed

+5
-7
lines changed
Filter options

1 file changed

+5
-7
lines changed

‎src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/base_js.html.twig

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/base_js.html.twig
+5-7Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -418,12 +418,10 @@
418418
'{{ path("_wdt", { "token": "xxxxxx" }) }}'.replace(/xxxxxx/, newToken),
419419
function(xhr, el) {
420420
421-
/* Evaluate embedded scripts inside the toolbar */
422-
var i, scripts = [].slice.call(el.querySelectorAll('script'));
423-
424-
for (i = 0; i < scripts.length; ++i) {
425-
eval(scripts[i].firstChild.nodeValue);
426-
}
421+
/* Evaluate in global scope scripts embedded inside the toolbar */
422+
eval.call({}, ([].slice.call(el.querySelectorAll('script')).map(function (script) {
423+
return script.firstChild.nodeValue;
424+
}).join('\n')));
427425
428426
el.style.display = -1 !== xhr.responseText.indexOf('sf-toolbarreset') ? 'block' : 'none';
429427
@@ -442,7 +440,7 @@
442440
}
443441
444442
/* Handle toolbar-info position */
445-
var toolbarBlocks = [].slice.call(el.querySelectorAll('.sf-toolbar-block'));
443+
var i, toolbarBlocks = [].slice.call(el.querySelectorAll('.sf-toolbar-block'));
446444
for (i = 0; i < toolbarBlocks.length; ++i) {
447445
toolbarBlocks[i].onmouseover = function () {
448446
var toolbarInfo = this.querySelectorAll('.sf-toolbar-info')[0];

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.