@vueuse/head
Advanced tools
Comparing version 0.7.0 to 0.7.1
@@ -95,2 +95,16 @@ var __create = Object.create; | ||
// src/utils.ts | ||
function isEqualNode(oldTag, newTag) { | ||
if (oldTag instanceof HTMLElement && newTag instanceof HTMLElement) { | ||
const nonce = newTag.getAttribute("nonce"); | ||
if (nonce && !oldTag.getAttribute("nonce")) { | ||
const cloneTag = newTag.cloneNode(true); | ||
cloneTag.setAttribute("nonce", ""); | ||
cloneTag.nonce = nonce; | ||
return nonce === oldTag.nonce && oldTag.isEqualNode(cloneTag); | ||
} | ||
} | ||
return oldTag.isEqualNode(newTag); | ||
} | ||
// src/index.ts | ||
@@ -179,2 +193,3 @@ var getTagKey = (props) => { | ||
const headCount = headCountEl ? Number(headCountEl.getAttribute("content")) : 0; | ||
const uncontrolledElements = []; | ||
const oldElements = []; | ||
@@ -193,3 +208,3 @@ if (headCountEl) { | ||
} | ||
const newElements = []; | ||
let newElements = []; | ||
let title; | ||
@@ -219,3 +234,3 @@ let htmlAttrs = {}; | ||
if (!oldElements.includes(el)) { | ||
oldElements.push(el); | ||
uncontrolledElements.push(el); | ||
} | ||
@@ -227,2 +242,15 @@ } | ||
} | ||
newElements = newElements.filter((newEl) => { | ||
for (let k = 0, len = oldElements.length; k < len; k++) { | ||
const oldEl = oldElements[k]; | ||
if (isEqualNode(oldEl, newEl)) { | ||
oldElements.splice(k, 1); | ||
return false; | ||
} | ||
} | ||
return true; | ||
}); | ||
uncontrolledElements.forEach((el) => { | ||
el.remove(); | ||
}); | ||
oldElements.forEach((el) => { | ||
@@ -234,2 +262,5 @@ if (el.nextSibling && el.nextSibling.nodeType === Node.TEXT_NODE) { | ||
}); | ||
newElements.forEach((el) => { | ||
head.insertBefore(el, headCountEl); | ||
}); | ||
if (title !== void 0) { | ||
@@ -240,6 +271,3 @@ document.title = title; | ||
setAttrs(document.body, bodyAttrs); | ||
newElements.forEach((el) => { | ||
head.insertBefore(el, headCountEl); | ||
}); | ||
headCountEl.setAttribute("content", "" + newElements.length); | ||
headCountEl.setAttribute("content", "" + (headCount - oldElements.length + newElements.length)); | ||
}; | ||
@@ -246,0 +274,0 @@ var createHead = () => { |
{ | ||
"name": "@vueuse/head", | ||
"version": "0.7.0", | ||
"version": "0.7.1", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "description": "Document head manager for Vue 3. SSR ready.", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
32516
878