diff --git a/src/client/app/composables/head.ts b/src/client/app/composables/head.ts index d0000a3c..708c16eb 100644 --- a/src/client/app/composables/head.ts +++ b/src/client/app/composables/head.ts @@ -17,14 +17,13 @@ export function useUpdateHead(route: Route, siteDataByRouteRef: Ref) { // skip the first update. isFirstUpdate = false newTags.forEach((tag) => { - const selector = toSelector(tag[0], tag[1]) const headEl = createHeadElement(tag) - ;[...document.querySelectorAll(selector)].some((el) => { + for (const el of document.head.children) { if (el.isEqualNode(headEl)) { managedHeadElements.push(el as HTMLElement) - return true + return } - }) + } }) return } @@ -106,9 +105,3 @@ function isMetaDescription(headConfig: HeadConfig) { function filterOutHeadDescription(head: HeadConfig[]) { return head.filter((h) => !isMetaDescription(h)) } - -function toSelector(tag: string, attrs: Record) { - return `${tag}${Object.keys(attrs) - .map((key) => `[${key}="${attrs[key].replace(/(["'\\])/g, '\\$1')}"]`) - .join('')}` -}