10000 bug #26119 [TwigBundle][WebProfilerBundle] Fix JS collision (ro0NL) · symfony/symfony@267bf4c · GitHub
[go: up one dir, main page]

Skip to content

Commit 267bf4c

Browse files
committed
bug #26119 [TwigBundle][WebProfilerBundle] Fix JS collision (ro0NL)
This PR was merged into the 3.4 branch. Discussion ---------- [TwigBundle][WebProfilerBundle] Fix JS collision | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes/no | Fixed tickets | #25894 | License | MIT | Doc PR | symfony/symfony-docs#... <!--highly recommended for new features--> <!-- - Bug fixes must be submitted against the lowest branch where they apply (lowest branches are regularly merged to upper ones so they get the fixes too). - Features and deprecations must be submitted against the master branch. - Replace this comment by a description of what your PR is solving. --> Commits ------- da39e01 [TwigBundle][WebProfilerBundle] Fix JS collision
2 parents 9a9c0f6 + da39e01 commit 267bf4c

File tree

2 files changed

+26
-18
lines changed

2 files changed

+26
-18
lines changed

src/Symfony/Bundle/TwigBundle/Resources/views/base_js.html.twig

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
addEventListener: addEventListener,
3838
3939
createTabs: function() {
40-
var tabGroups = document.querySelectorAll('.sf-tabs');
40+
var tabGroups = document.querySelectorAll('.sf-tabs:not([data-processed=true])');
4141
4242
/* create the tab navigation for each group of tabs */
4343
for (var i = 0; i < tabGroups.length; i++) {
@@ -99,11 +99,13 @@
9999
document.getElementById(activeTabId).className = 'block';
100100
});
101101
}
102+
103+
tabGroups[i].setAttribute('data-processed', 'true');
102104
}
103105
},
104106
105107
createToggles: function() {
106-
var toggles = document.querySelectorAll('.sf-toggle');
108+
var toggles = document.querySelectorAll('.sf-toggle:not([data-processed=true])');
107109
108110
for (var i = 0; i < toggles.length; i++) {
109111
var elementSelector = toggles[i].getAttribute('data-toggle-selector');
@@ -156,14 +158,16 @@
156158
var altContent = toggle.getAttribute('data-toggle-alt-content');
157159
toggle.innerHTML = currentContent !== altContent ? altContent : originalContent;
158160
});
159-
}
160161
161-
/* Prevents from disallowing clicks on links inside toggles */
162-
var toggleLinks = document.querySelectorAll('.sf-toggle a');
163-
for (var i = 0; i < toggleLinks.length; i++) {
164-
addEventListener(toggleLinks[i], 'click', function(e) {
165-
e.stopPropagation();
166-
});
162+
/* Prevents from disallowing clicks on links inside toggles */
163+
var toggleLinks = toggles[i].querySelectorAll('a');
164+
for (var j = 0; j < toggleLinks.length; j++) {
165+
addEventListener(toggleLinks[j], 'click', function(e) {
166+
e.stopPropagation();
167+
});
168+
}
169+
170+
toggles[i].setAttribute('data-processed', 'true');
167171
}
168172
}
169173
};

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

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@
393393
},
394394
395395
createTabs: function() {
396-
var tabGroups = document.querySelectorAll('.sf-tabs');
396+
var tabGroups = document.querySelectorAll('.sf-tabs:not([data-processed=true])');
397397
398398
/* create the tab navigation for each group of tabs */
399399
for (var i = 0; i < tabGroups.length; i++) {
@@ -455,11 +455,13 @@
455455
document.getElementById(activeTabId).className = 'block';
456456
});
457457
}
458+
459+
tabGroups[i].setAttribute('data-processed', 'true');
458460
}
459461
},
460462
461463
createToggles: function() {
462-
var toggles = document.querySelectorAll('.sf-toggle');
464+
var toggles = document.querySelectorAll('.sf-toggle:not([data-processed=true])');
463465
464466
for (var i = 0; i < toggles.length; i++) {
465467
var elementSelector = toggles[i].getAttribute('data-toggle-selector');
@@ -512,14 +514,16 @@
512514
var altContent = toggle.getAttribute('data-toggle-alt-content');
513515
toggle.innerHTML = currentContent !== altContent ? altContent : originalContent;
514516
});
515-
}
516517
517-
/* Prevents from disallowing clicks on links inside toggles */
518-
var toggleLinks = document.querySelectorAll('.sf-toggle a');
519-
for (var i = 0; i < toggleLinks.length; i++) {
520-
addEventListener(toggleLinks[i], 'click', function(e) {
521-
e.stopPropagation();
522-
});
518+
/* Prevents from disallowing clicks on links inside toggles */
519+
var toggleLinks = toggles[i].querySelectorAll('a');
520+
for (var j = 0; j < toggleLinks.length; j++) {
521+
addEventListener(toggleLinks[j], 'click', function(e) {
522+
e.stopPropagation();
523+
});
524+
}
525+
526+
toggles[i].setAttribute('data-processed', 'true');
523527
}
524528
}
525529
};

0 commit comments

Comments
 (0)
0