also set attributes on created style nodes

This commit is contained in:
BurningTreeC 2024-03-31 19:17:09 +02:00
parent c2618bf208
commit 73299d93e8
2 changed files with 12 additions and 0 deletions

View File

@ -68,6 +68,9 @@ exports.startup = function() {
if($tw.styleWidgets.length) {
for(var i=0; i<$tw.styleWidgets.length; i++) {
styleElement = document.createElement("style");
for(var key in $tw.styleWidgets[i].attributes) {
styleElement.setAttribute(key,$tw.styleWidgets[i].attributes[key]);
}
styleElement.innerHTML = $tw.styleWidgets[i].textContent;
$tw.styleElements.push(styleElement);
document.head.insertBefore(styleElement,insertBeforeElement);
@ -88,6 +91,9 @@ exports.startup = function() {
newStyles = styleWidgets[i].textContent;
if(!$tw.styleElements[i]) {
styleElement = document.createElement("style");
for(var key in styleWidgets[i].attributes) {
styleElement.setAttribute(key,styleWidgets[i].attributes[key]);
}
document.head.insertBefore(styleElement,$tw.styleElements[i] || $tw.styleElements[i - 1].nextSibling);
$tw.styleElements.splice(i,0,styleElement);
}

View File

@ -97,6 +97,9 @@ exports.startup = function() {
if($tw.styleWidgets.length) {
for(var i=0; i<$tw.styleWidgets.length; i++) {
styleElement = srcDocument.createElement("style");
for(var key in $tw.styleWidgets[i].attributes) {
styleElement.setAttribute(key,$tw.styleWidgets[i].attributes[key]);
}
styleElement.innerHTML = $tw.styleWidgets[i].textContent;
$tw.windows[windowID].styleElements.push(styleElement);
srcDocument.head.insertBefore(styleElement,insertBeforeElement);
@ -122,6 +125,9 @@ exports.startup = function() {
newStyles = styleWidgets[i].textContent;
if(!$tw.windows[windowID].styleElements[i]) {
styleElement = srcDocument.createElement("style");
for(var key in styleWidgets[i].attributes) {
styleElement.setAttribute(key,styleWidgets[i].attributes[key]);
}
srcDocument.head.insertBefore(styleElement,$tw.windows[windowID].styleElements[i] || $tw.windows[windowID].styleElements[i - 1].nextSibling);
$tw.windows[windowID].styleElements.splice(i,0,styleElement);
}