Pre Release New Changes
This commit is contained in:
@@ -69,6 +69,59 @@ export const NAV_RUNTIME = String.raw`
|
||||
return rel.indexOf("external") === -1;
|
||||
}
|
||||
|
||||
function currentDocumentNonce() {
|
||||
var node = document.querySelector("script[nonce],style[nonce]");
|
||||
if (!node) return "";
|
||||
return node.nonce || node.getAttribute("nonce") || "";
|
||||
}
|
||||
|
||||
function syncWrnStyles(nextDocument) {
|
||||
var current = Array.prototype.slice.call(
|
||||
document.querySelectorAll("style[data-wrnexus-style-id]"),
|
||||
);
|
||||
var next = Array.prototype.slice.call(
|
||||
nextDocument.querySelectorAll("style[data-wrnexus-style-id]"),
|
||||
);
|
||||
var currentById = Object.create(null);
|
||||
var nextIds = Object.create(null);
|
||||
var nonce = currentDocumentNonce();
|
||||
|
||||
current.forEach(function (style) {
|
||||
var id = style.getAttribute("data-wrnexus-style-id");
|
||||
if (id) currentById[id] = style;
|
||||
});
|
||||
|
||||
next.forEach(function (nextStyle) {
|
||||
var id = nextStyle.getAttribute("data-wrnexus-style-id");
|
||||
if (!id) return;
|
||||
nextIds[id] = true;
|
||||
|
||||
var currentStyle = currentById[id];
|
||||
if (!currentStyle) {
|
||||
currentStyle = document.createElement("style");
|
||||
currentStyle.setAttribute("data-wrnexus-style-id", id);
|
||||
}
|
||||
|
||||
["data-wrnexus-style-owner", "data-wrnexus-style-kind"].forEach(function (name) {
|
||||
var value = nextStyle.getAttribute(name);
|
||||
if (value == null) currentStyle.removeAttribute(name);
|
||||
else currentStyle.setAttribute(name, value);
|
||||
});
|
||||
|
||||
if (nonce) currentStyle.setAttribute("nonce", nonce);
|
||||
if (currentStyle.textContent !== nextStyle.textContent) {
|
||||
currentStyle.textContent = nextStyle.textContent;
|
||||
}
|
||||
|
||||
document.head.appendChild(currentStyle);
|
||||
});
|
||||
|
||||
current.forEach(function (style) {
|
||||
var id = style.getAttribute("data-wrnexus-style-id");
|
||||
if (id && !nextIds[id]) style.remove();
|
||||
});
|
||||
}
|
||||
|
||||
function loadedScriptPaths() {
|
||||
var loaded = {};
|
||||
|
||||
@@ -317,6 +370,8 @@ export const NAV_RUNTIME = String.raw`
|
||||
document.title = doc.title;
|
||||
}
|
||||
|
||||
syncWrnStyles(doc);
|
||||
|
||||
var importedNodes = [];
|
||||
|
||||
for (
|
||||
|
||||
Reference in New Issue
Block a user