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

Appearance settings

Commit 354f063

Browse filesBrowse files
committed
[Fix] functional SFC style injection support
1 parent 8e34bad commit 354f063
Copy full SHA for 354f063

File tree

Expand file treeCollapse file tree

1 file changed

+11
-2
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+11
-2
lines changed

‎lib/component-normalizer.js

Copy file name to clipboardExpand all lines: lib/component-normalizer.js
+11-2Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,18 @@ module.exports = function normalizeComponent (
6161
hook = injectStyles
6262
}
6363

64-
if (hook) {
64+
var existing = options.functional ? options.render : options.beforeCreate
65+
66+
if (hook && options.functional && injectStyles) {
67+
// inject styles for functioal component in vue file
68+
options.render = function renderWithStyleInjection (h, context) {
69+
hook(context)
70+
return existing(h, context)
71+
}
72+
}
73+
74+
if (hook && !options.functional) {
6575
// inject component registration as beforeCreate hook
66-
var existing = options.beforeCreate
6776
options.beforeCreate = existing
6877
? [].concat(existing, hook)
6978
: [hook]

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.