Skip to content

Commit 2409ff0

Browse files
committed
feat(ssr): wrap script in IIFE
Wrap auto-remove script in IIFE so that global scope is not polluted. vuejs#6761
1 parent 6bb389d commit 2409ff0

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/server/template-renderer/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ export default class TemplateRenderer {
192192
windowKey = '__INITIAL_STATE__'
193193
} = options || {}
194194
const autoRemove = process.env.NODE_ENV === 'production'
195-
? 'var s;(s=document.currentScript||document.scripts[document.scripts.length-1]).parentNode.removeChild(s);'
195+
? '(function(){var s;(s=document.currentScript||document.scripts[document.scripts.length-1]).parentNode.removeChild(s);}());'
196196
: ''
197197
return context[contextKey]
198198
? `<script>window.${windowKey}=${

0 commit comments

Comments
 (0)