mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-23 14:15:13 +00:00
fix: SafariFix is not injected in client modern mode
This commit is contained in:
parent
a053e58534
commit
ecf76d91f1
@ -77,13 +77,6 @@ export default class ModernModePlugin {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// inject Safari 10 nomodule fix
|
|
||||||
data.body.push({
|
|
||||||
tagName: 'script',
|
|
||||||
closeTag: true,
|
|
||||||
innerHTML: ModernModePlugin.safariFix
|
|
||||||
})
|
|
||||||
|
|
||||||
// inject links for legacy assets as <script nomodule>
|
// inject links for legacy assets as <script nomodule>
|
||||||
const fileName = data.plugin.options.filename
|
const fileName = data.plugin.options.filename
|
||||||
const legacyAssets = (await this.getAssets(fileName))
|
const legacyAssets = (await this.getAssets(fileName))
|
||||||
@ -100,6 +93,12 @@ export default class ModernModePlugin {
|
|||||||
|
|
||||||
compilation.hooks.htmlWebpackPluginAfterHtmlProcessing.tap(ID, (data) => {
|
compilation.hooks.htmlWebpackPluginAfterHtmlProcessing.tap(ID, (data) => {
|
||||||
data.html = data.html.replace(/\snomodule="">/g, ' nomodule>')
|
data.html = data.html.replace(/\snomodule="">/g, ' nomodule>')
|
||||||
|
|
||||||
|
// inject Safari 10 nomodule fix
|
||||||
|
data.html = data.html.replace(
|
||||||
|
/(<\/body\s*>)/i,
|
||||||
|
match => `<script>${ModernModePlugin.safariFix}</script>${match}`
|
||||||
|
)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -39,6 +39,11 @@ describe('modern client mode (SSR)', () => {
|
|||||||
].join(', '))
|
].join(', '))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test('should contain safari fix script', async () => {
|
||||||
|
const response = await rp(url('/'))
|
||||||
|
expect(response).toContain('"noModule"')
|
||||||
|
})
|
||||||
|
|
||||||
// Close server and ask nuxt to stop listening to file changes
|
// Close server and ask nuxt to stop listening to file changes
|
||||||
afterAll(async () => {
|
afterAll(async () => {
|
||||||
await nuxt.close()
|
await nuxt.close()
|
||||||
|
Loading…
Reference in New Issue
Block a user