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.
This commit is contained in:
Richard Hansen 2021-06-18 00:52:34 -04:00
parent 7bdd0f2f09
commit 9fcd86b3cd

View file

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