mirror of
https://gitee.com/vuejs/vue.git
synced 2024-12-03 12:38:24 +08:00
refactor: avoid using Object.assign in SSR code for basic renderer compat in other environments
This commit is contained in:
parent
ef358fef94
commit
e76e648bc8
@ -2,6 +2,7 @@
|
||||
|
||||
process.env.VUE_ENV = 'server'
|
||||
|
||||
import { extend } from 'shared/util'
|
||||
import modules from './server/modules/index'
|
||||
import baseDirectives from './server/directives/index'
|
||||
import { isUnaryTag, canBeLeftOpenTag } from './compiler/util'
|
||||
@ -13,13 +14,13 @@ export function createRenderer (options?: Object = {}): {
|
||||
renderToString: Function,
|
||||
renderToStream: Function
|
||||
} {
|
||||
return _createRenderer(Object.assign({}, options, {
|
||||
return _createRenderer(extend(extend({}, options), {
|
||||
isUnaryTag,
|
||||
canBeLeftOpenTag,
|
||||
modules,
|
||||
// user can provide server-side implementations for custom directives
|
||||
// when creating the renderer.
|
||||
directives: Object.assign(baseDirectives, options.directives)
|
||||
directives: extend(baseDirectives, options.directives)
|
||||
}))
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,8 @@ import { escape } from '../util'
|
||||
|
||||
import {
|
||||
isDef,
|
||||
isUndef
|
||||
isUndef,
|
||||
extend
|
||||
} from 'shared/util'
|
||||
|
||||
import {
|
||||
@ -22,7 +23,7 @@ export default function renderAttrs (node: VNodeWithData): string {
|
||||
let parent = node.parent
|
||||
while (isDef(parent)) {
|
||||
if (isDef(parent.data) && isDef(parent.data.attrs)) {
|
||||
attrs = Object.assign({}, attrs, parent.data.attrs)
|
||||
attrs = extend(extend({}, attrs), parent.data.attrs)
|
||||
}
|
||||
parent = parent.parent
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
import VNode from 'core/vdom/vnode'
|
||||
import { renderAttr } from './attrs'
|
||||
import { isDef, isUndef } from 'shared/util'
|
||||
import { isDef, isUndef, extend } from 'shared/util'
|
||||
import { propsToAttrMap, isRenderableAttr } from '../util'
|
||||
|
||||
export default function renderDOMProps (node: VNodeWithData): string {
|
||||
@ -12,7 +12,7 @@ export default function renderDOMProps (node: VNodeWithData): string {
|
||||
let parent = node.parent
|
||||
while (isDef(parent)) {
|
||||
if (parent.data && parent.data.domProps) {
|
||||
props = Object.assign({}, props, parent.data.domProps)
|
||||
props = extend(extend({}, props), parent.data.domProps)
|
||||
}
|
||||
parent = parent.parent
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ export function installSSRHelpers (vm: Component) {
|
||||
while (Ctor.super) {
|
||||
Ctor = Ctor.super
|
||||
}
|
||||
Object.assign(Ctor.prototype, {
|
||||
extend(Ctor.prototype, {
|
||||
_ssrEscape: escape,
|
||||
_ssrNode: renderStringNode,
|
||||
_ssrList: renderStringList,
|
||||
|
@ -3,7 +3,8 @@
|
||||
import {
|
||||
isDef,
|
||||
isUndef,
|
||||
isTrue
|
||||
isTrue,
|
||||
extend
|
||||
} from 'shared/util'
|
||||
|
||||
import { escape } from 'web/server/util'
|
||||
@ -29,7 +30,7 @@ const normalizeRender = vm => {
|
||||
const { render, template, _scopeId } = vm.$options
|
||||
if (isUndef(render)) {
|
||||
if (template) {
|
||||
Object.assign(vm.$options, ssrCompileToFunctions(template, {
|
||||
extend(vm.$options, ssrCompileToFunctions(template, {
|
||||
scopeId: _scopeId
|
||||
}))
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user