Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
forked fromvuejs/vue

Commita2f73f2

Browse files
committed
fix(ssr): fix style injection regression
fixvuejs#6603, (regression caused by attempt tofixvuejs#6353)
1 parent0c9534f commita2f73f2

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

‎src/server/bundle-renderer/create-bundle-runner.js

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ export function createBundleRunner (entry, files, basedir, runInNewContext) {
106106
// slightly differently.
107107
letrunner// lazy creation so that errors can be caught by user
108108
letinitialContext
109-
return(userContext={})=>newPromise((resolve,reject)=>{
109+
return(userContext={})=>newPromise(resolve=>{
110110
if(!runner){
111111
constsandbox=runInNewContext==='once'
112112
?createSandbox()
@@ -126,27 +126,25 @@ export function createBundleRunner (entry, files, basedir, runInNewContext) {
126126
}
127127
}
128128
userContext._registeredComponents=newSet()
129+
129130
// vue-style-loader styles imported outside of component lifecycle hooks
130131
if(initialContext._styles){
131132
userContext._styles=deepClone(initialContext._styles)
132-
}
133-
// #6353 after the app is resolved, if the userContext doesn't have a
134-
// styles property, it means the app doesn't have any lifecycle-injected
135-
// styles, so vue-style-loader never defined the styles getter.
136-
// just expose the same styles from the initialContext.
137-
constexposeStylesAndResolve=app=>{
138-
if(!userContext.hasOwnProperty('styles')){
139-
userContext.styles=initialContext.styles
133+
// #6353 ensure "styles" is exposed even if no styles are injected
134+
// in component lifecycles.
135+
// the renderStyles fn is exposed by vue-style-loader >= 3.0.3
136+
constrenderStyles=initialContext._renderStyles
137+
if(renderStyles){
138+
Object.defineProperty(userContext,'styles',{
139+
enumerable:true,
140+
get(){
141+
returnrenderStyles(userContext._styles)
142+
}
143+
})
140144
}
141-
resolve(app)
142145
}
143146

144-
constres=runner(userContext)
145-
if(typeofres.then==='function'){
146-
res.then(exposeStylesAndResolve).catch(reject)
147-
}else{
148-
exposeStylesAndResolve(res)
149-
}
147+
resolve(runner(userContext))
150148
})
151149
}
152150
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp