Skip to content

Commit 2790b0c

Browse files
fix(head): use innerHTML instead of children
1 parent bbb6c6a commit 2790b0c

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/module.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { resolve } from 'pathe'
21
import type { MetaObject } from '@nuxt/schema'
3-
import { defineNuxtModule, isNuxt2, resolvePath, useLogger } from '@nuxt/kit'
2+
import { defineNuxtModule, isNuxtMajorVersion, resolvePath, useLogger } from '@nuxt/kit'
3+
import { resolve } from 'pathe'
44
import { constructURL, download, isValidURL, parse, merge, type DownloadOptions, type GoogleFonts } from 'google-fonts-helper'
55
import { name, version } from '../package.json'
66

@@ -184,7 +184,7 @@ export default defineNuxtModule<ModuleOptions>({
184184
return
185185
}
186186

187-
if (isNuxt2()) {
187+
if (isNuxtMajorVersion(2, nuxt)) {
188188
// JS to inject CSS
189189
head.script.push({
190190
key: 'gf-script',
@@ -212,7 +212,7 @@ export default defineNuxtModule<ModuleOptions>({
212212
// JS to inject CSS
213213
head.script.unshift({
214214
key: 'gf-script',
215-
children: `(function(){
215+
innerHTML: `(function(){
216216
var h=document.querySelector("head");
217217
var m=h.querySelector('meta[name="head:count"]');
218218
if(m){m.setAttribute('content',Number(m.getAttribute('content'))+1);}
@@ -223,7 +223,7 @@ export default defineNuxtModule<ModuleOptions>({
223223

224224
// no-JS fallback
225225
head.noscript.push({
226-
children: `<link rel="stylesheet" href="${url}">`,
226+
innerHTML: `<link rel="stylesheet" href="${url}">`,
227227
tagPosition: 'bodyOpen',
228228
})
229229
},

0 commit comments

Comments
 (0)