Skip to content

Commit 354f063

Browse files
committed
[Fix] functional SFC style injection support
1 parent 8e34bad commit 354f063

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

lib/component-normalizer.js

Lines 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)