mirror of
https://github.com/casdoor/casdoor.git
synced 2025-05-23 02:35:49 +08:00
feat: fix headerHtml script not running bug (#2749)
* fix: fix custom head not exec <script> tag * fix: fix create element bug
This commit is contained in:
parent
e4cf244cf8
commit
6a813a1f8c
@ -23,8 +23,21 @@ function CustomHead(props) {
|
||||
node.innerHTML = props.headerHtml;
|
||||
|
||||
node.childNodes.forEach(el => {
|
||||
el.setAttribute("app-custom-head" + suffix, "");
|
||||
document.head.appendChild(el);
|
||||
if (el.nodeName === "#text") {
|
||||
return;
|
||||
}
|
||||
let innerNode = el;
|
||||
innerNode.setAttribute("app-custom-head" + suffix, "");
|
||||
|
||||
if (innerNode.localName === "script") {
|
||||
const scriptNode = document.createElement("script");
|
||||
Array.from(innerNode.attributes).forEach(attr => {
|
||||
scriptNode.setAttribute(attr.name, attr.value);
|
||||
});
|
||||
scriptNode.text = innerNode.textContent;
|
||||
innerNode = scriptNode;
|
||||
}
|
||||
document.head.appendChild(innerNode);
|
||||
});
|
||||
|
||||
return () => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user