Skip to content

Commit a077670

Browse files
[5.x] Fix nocache tag not replacing element correctly (#13177)
1 parent db9856f commit a077670

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

src/StaticCaching/Cachers/FileCacher.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,19 @@ function createMap() {
251251
return map;
252252
}
253253
254+
function replaceElement(el, html) {
255+
const tmp = document.createElement('div');
256+
const fragment = document.createDocumentFragment();
257+
258+
tmp.setHTMLUnsafe(html);
259+
260+
while (tmp.firstChild) {
261+
fragment.appendChild(tmp.firstChild);
262+
}
263+
264+
el.replaceWith(fragment);
265+
}
266+
254267
var map = createMap();
255268
256269
fetch('/!/nocache', {
@@ -267,7 +280,7 @@ function createMap() {
267280
268281
const regions = data.regions;
269282
for (var key in regions) {
270-
if (map[key]) map[key].setHTMLUnsafe(regions[key]);
283+
if (map[key]) replaceElement(map[key], regions[key]);
271284
}
272285
273286
for (const input of document.querySelectorAll('input[value="$csrfPlaceholder"]')) {

0 commit comments

Comments
 (0)