-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(ssr): expose context.styles when no lifecycle styles are injected
fix #6353
- Loading branch information
Showing
1 changed file
with
17 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -130,7 +130,23 @@ export function createBundleRunner (entry, files, basedir, runInNewContext) { | |
if (initialContext._styles) { | ||
userContext._styles = deepClone(initialContext._styles) | ||
} | ||
resolve(runner(userContext)) | ||
// #6353 after the app is resolved, if the userContext doesn't have a | ||
// styles property, it means the app doesn't have any lifecycle-injected | ||
// styles, so vue-style-loader never defined the styles getter. | ||
// just expose the same styles from the initialContext. | ||
const exposeStylesAndResolve = app => { | ||
if (!userContext.hasOwnProperty('styles')) { | ||
userContext.styles = initialContext.styles | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
yyx990803
Author
Member
|
||
} | ||
resolve(app) | ||
} | ||
|
||
const res = runner(userContext) | ||
if (typeof res.then === 'function') { | ||
res.then(exposeStylesAndResolve) | ||
} else { | ||
exposeStylesAndResolve(res) | ||
} | ||
}) | ||
} | ||
} |
What if user wants to add some custom style into
userContext._styles
in this case?For example I'm generating theme style via string template manually and injecting them into
userContext._styles
.