Pad: Fix `<script>` elements in `aceInitInnerdocbodyHead` hook

Using `.innerHTML` to create a `<script>` element does create a DOM
node, but the script is not actually executed. Fortunately, creating a
DocumentFragment does cause the script to execute.
pull/5091/head
Richard Hansen 2021-06-18 00:52:34 -04:00
parent 7bdd0f2f09
commit 9fcd86b3cd
1 changed files with 2 additions and 3 deletions

View File

@ -278,9 +278,8 @@ const Ace2Editor = function () {
innerDocument.head.appendChild(innerStyle);
const headLines = [];
hooks.callAll('aceInitInnerdocbodyHead', {iframeHTML: headLines});
const tmp = innerDocument.createElement('div');
tmp.innerHTML = headLines.join('\n');
while (tmp.firstChild) innerDocument.head.appendChild(tmp.firstChild);
innerDocument.head.appendChild(
innerDocument.createRange().createContextualFragment(headLines.join('\n')));
// <body> tag
innerDocument.body.id = 'innerdocbody';