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 741bcd2

Browse filesBrowse files
committed
refactor: tweak normalizer
1 parent da9433e commit 741bcd2
Copy full SHA for 741bcd2

File tree

4 files changed

+15
-26
lines changed
Filter options

4 files changed

+15
-26
lines changed

‎lib/runtime/component-normalizer.js

Copy file name to clipboardExpand all lines: lib/runtime/component-normalizer.js
+12-19Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -68,35 +68,28 @@ export default function normalizeComponent (
6868
// never gets called
6969
options._ssrRegister = hook
7070
} else if (injectStyles) {
71-
if (shadowMode) {
72-
hook = function () {
73-
injectStyles(this.$root.$options.shadowRoot)
74-
}
75-
} else {
76-
hook = injectStyles
77-
}
71+
hook = shadowMode
72+
? function () { injectStyles(this.$root.$options.shadowRoot) }
73+
: injectStyles
7874
}
7975

8076
if (hook) {
81-
var functional = options.functional
82-
var existing = functional
83-
? options.render
84-
: options.beforeCreate
85-
86-
if (!functional) {
87-
// inject component registration as beforeCreate hook
88-
options.beforeCreate = existing
89-
? [].concat(existing, hook)
90-
: [hook]
91-
} else {
77+
if (options.functional) {
9278
// for template-only hot-reload because in that case the render fn doesn't
9379
// go through the normalizer
9480
options._injectStyles = hook
9581
// register for functioal component in vue file
82+
var render = options.render
9683
options.render = function renderWithStyleInjection (h, context) {
9784
hook.call(context)
98-
return existing(h, context)
85+
return render(h, context)
9986
}
87+
} else {
88+
// inject component registration as beforeCreate hook
89+
var existing = options.beforeCreate
90+
options.beforeCreate = existing
91+
? [].concat(existing, hook)
92+
: [hook]
10093
}
10194
}
10295

‎test.html

Copy file name to clipboardExpand all lines: test.html
-1Lines changed: 0 additions & 1 deletion
This file was deleted.

‎test/fixtures/service.js

Copy file name to clipboardExpand all lines: test/fixtures/service.js
-3Lines changed: 0 additions & 3 deletions
This file was deleted.

‎test/fixtures/ssr-style.js

Copy file name to clipboard
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
var Vue = require('vue')
2-
var App = require('./ssr-style.vue').default
1+
import Vue from 'vue'
2+
import App from './ssr-style.vue'
33

4-
module.exports = () => new Vue({
4+
export default () => new Vue({
55
render: h => h(App)
66
})

0 commit comments

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