Skip to content

Commit 69ecdcb

Browse files
committed
rename vnode.data.props -> domProps
1 parent b46baac commit 69ecdcb

File tree

11 files changed

+34
-34
lines changed

11 files changed

+34
-34
lines changed

Diff for: flow/vnode.js

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ declare interface VNodeData {
4141
show?: true;
4242
props?: { [key: string]: any };
4343
attrs?: { [key: string]: string };
44+
domProps?: { [key: string]: any };
4445
staticAttrs?: { [key: string]: string };
4546
hook?: { [key: string]: Function };
4647
on?: { [key: string]: Function | Array<Function> };

Diff for: src/compiler/codegen.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,6 @@ function genData (el: ASTElement): string | void {
146146
if (el.attrsMap['v-show']) {
147147
data += 'show:true,'
148148
}
149-
// props
150-
if (el.props) {
151-
data += `props:{${genProps(el.props)}},`
152-
}
153149
// attributes
154150
if (el.attrs) {
155151
data += `attrs:{${genProps(el.attrs)}},`
@@ -158,6 +154,10 @@ function genData (el: ASTElement): string | void {
158154
if (el.staticAttrs) {
159155
data += `staticAttrs:{${genProps(el.staticAttrs)}},`
160156
}
157+
// DOM props
158+
if (el.props) {
159+
data += `domProps:{${genProps(el.props)}},`
160+
}
161161
// hooks
162162
if (el.hooks) {
163163
data += `hook:{${genHooks(el.hooks)}},`

Diff for: src/core/instance/render.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ export function renderMixin (Vue: Class<Component>) {
162162
const data = vnode.data
163163
for (const key in value) {
164164
const hash = config.mustUseProp(key)
165-
? data.props || (data.props = {})
165+
? data.domProps || (data.domProps = {})
166166
: data.attrs || (data.attrs = {})
167167
hash[key] = value[key]
168168
}

Diff for: src/core/vdom/create-component.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -222,16 +222,15 @@ function extractProps (data: VNodeData, Ctor: Class<Component>): ?Object {
222222
return
223223
}
224224
const res = {}
225-
const attrs = data.attrs
226-
const props = data.props
227-
const staticAttrs = data.staticAttrs
228-
if (!attrs && !props && !staticAttrs) {
225+
const { attrs, props, domProps, staticAttrs } = data
226+
if (!attrs && !props && !domProps && !staticAttrs) {
229227
return res
230228
}
231229
for (const key in propOptions) {
232230
const altKey = hyphenate(key)
233231
checkProp(res, attrs, key, altKey) ||
234232
checkProp(res, props, key, altKey) ||
233+
checkProp(res, domProps, key, altKey) ||
235234
checkProp(res, staticAttrs, key, altKey)
236235
}
237236
return res

Diff for: src/platforms/web/runtime/modules/props.js renamed to src/platforms/web/runtime/modules/dom-props.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
/* @flow */
22

3-
function updateProps (oldVnode: VNodeWithData, vnode: VNodeWithData) {
4-
if (!oldVnode.data.props && !vnode.data.props) {
3+
function updateDOMProps (oldVnode: VNodeWithData, vnode: VNodeWithData) {
4+
if (!oldVnode.data.domProps && !vnode.data.domProps) {
55
return
66
}
77
let key, cur
88
const elm: any = vnode.elm
9-
const oldProps = oldVnode.data.props || {}
10-
const props = vnode.data.props || {}
11-
const clonedProps = vnode.data.props = {}
9+
const oldProps = oldVnode.data.domProps || {}
10+
const props = vnode.data.domProps || {}
11+
const clonedProps = vnode.data.domProps = {}
1212

1313
for (key in oldProps) {
1414
if (props[key] == null) {
@@ -32,6 +32,6 @@ function updateProps (oldVnode: VNodeWithData, vnode: VNodeWithData) {
3232
}
3333

3434
export default {
35-
create: updateProps,
36-
update: updateProps
35+
create: updateDOMProps,
36+
update: updateDOMProps
3737
}

Diff for: src/platforms/web/runtime/modules/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import attrs from './attrs'
22
import klass from './class'
33
import events from './events'
4-
import props from './props'
4+
import domProps from './dom-props'
55
import style from './style'
66
import transition from './transition'
77

88
export default [
99
attrs,
1010
klass,
1111
events,
12-
props,
12+
domProps,
1313
style,
1414
transition
1515
]

Diff for: src/platforms/web/server/modules/props.js renamed to src/platforms/web/server/modules/dom-props.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { renderAttr } from './attrs'
55
import { propsToAttrMap, isRenderableAttr } from 'web/util/attrs'
66

77
export default function (node: VNodeWithData): string {
8-
const props = node.data.props
8+
const props = node.data.domProps
99
let res = ''
1010
if (props) {
1111
for (const key in props) {

Diff for: src/platforms/web/server/modules/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import attrs from './attrs'
2-
import props from './props'
2+
import domProps from './dom-props'
33
import klass from './class'
44
import style from './style'
55

66
export default [
77
attrs,
8-
props,
8+
domProps,
99
klass,
1010
style
1111
]

Diff for: test/unit/modules/compiler/codegen.spec.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -153,10 +153,10 @@ describe('codegen', () => {
153153
)
154154
})
155155

156-
it('generate props with v-bind directive', () => {
156+
it('generate DOM props with v-bind directive', () => {
157157
assertCodegen(
158158
'<p :value="msg">',
159-
`with(this){return _h('p',{props:{"value":msg}})}`
159+
`with(this){return _h('p',{domProps:{"value":msg}})}`
160160
)
161161
})
162162

Diff for: test/unit/modules/vdom/modules/props.spec.js

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
import { patch } from 'web/runtime/patch'
22
import VNode from 'core/vdom/vnode'
33

4-
describe('vdom props module', () => {
5-
it('should create an element with props', () => {
6-
const vnode = new VNode('a', { props: { src: 'http://localhost/' }})
4+
describe('vdom domProps module', () => {
5+
it('should create an element with domProps', () => {
6+
const vnode = new VNode('a', { domProps: { src: 'http://localhost/' }})
77
const elm = patch(null, vnode)
88
expect(elm.src).toBe('http://localhost/')
99
})
1010

11-
it('should change the elements props', () => {
12-
const vnode1 = new VNode('a', { props: { src: 'http://localhost/' }})
13-
const vnode2 = new VNode('a', { props: { src: 'http://vuejs.org/' }})
11+
it('should change the elements domProps', () => {
12+
const vnode1 = new VNode('a', { domProps: { src: 'http://localhost/' }})
13+
const vnode2 = new VNode('a', { domProps: { src: 'http://vuejs.org/' }})
1414
patch(null, vnode1)
1515
const elm = patch(vnode1, vnode2)
1616
expect(elm.src).toBe('http://vuejs.org/')
1717
})
1818

19-
it('should remove the elements props', () => {
20-
const vnode1 = new VNode('a', { props: { src: 'http://localhost/' }})
21-
const vnode2 = new VNode('a', { props: {}})
19+
it('should remove the elements domProps', () => {
20+
const vnode1 = new VNode('a', { domProps: { src: 'http://localhost/' }})
21+
const vnode2 = new VNode('a', { domProps: {}})
2222
patch(null, vnode1)
2323
const elm = patch(vnode1, vnode2)
2424
expect(elm.src).toBeUndefined()

Diff for: test/unit/modules/vdom/patch/hydration.spec.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ describe('hydration', () => {
5050
traverseAndAssert(vnode1, node0)
5151

5252
// check update
53-
const vnode2 = new VNode('div', { props: { id: 'foo' }}, [
54-
new VNode('span', { props: { id: 'bar' }}),
53+
const vnode2 = new VNode('div', { attrs: { id: 'foo' }}, [
54+
new VNode('span', { attrs: { id: 'bar' }}),
5555
new VNode('div', { hook: { init }}, [
5656
new VNode('span', {}),
5757
new VNode('span', {})

0 commit comments

Comments
 (0)