@@ -49,16 +49,12 @@ module.exports = function compileProps (el, propOptions) {
49
49
attr = _ . hyphenate ( name )
50
50
value = el . getAttribute ( attr )
51
51
52
- if ( value !== null && process . env . NODE_ENV !== 'production' ) {
53
- _ . deprecation . PROPS ( attr , value )
54
- }
55
-
56
52
if ( value === null ) {
57
53
value = el . getAttribute ( 'data-' + attr )
58
54
if ( value !== null ) {
59
55
attr = 'data-' + attr
60
56
if ( process . env . NODE_ENV !== 'production' ) {
61
- _ . deprecation . PROPS ( attr , value )
57
+ _ . deprecation . DATA_PROPS ( attr , value )
62
58
}
63
59
}
64
60
}
@@ -77,6 +73,11 @@ module.exports = function compileProps (el, propOptions) {
77
73
el . removeAttribute ( attr )
78
74
var tokens = textParser . parse ( value )
79
75
if ( tokens ) {
76
+
77
+ if ( process . env . NODE_ENV !== 'production' ) {
78
+ _ . deprecation . PROPS ( attr , value )
79
+ }
80
+
80
81
prop . dynamic = true
81
82
prop . parentPath = textParser . tokensToExp ( tokens )
82
83
// check prop binding type.
@@ -100,30 +101,35 @@ module.exports = function compileProps (el, propOptions) {
100
101
}
101
102
}
102
103
} else {
103
- // new prop- syntax
104
- attr = 'prop -' + attr
104
+ // new syntax
105
+ attr = 'bind -' + attr
105
106
value = prop . raw = el . getAttribute ( attr )
106
107
if ( value !== null ) {
108
+ // mark it so we know this is a bind
109
+ prop . bindSyntax = true
107
110
el . removeAttribute ( attr )
111
+ value = value . trim ( )
108
112
// check binding type
109
113
if ( literalValueRE . test ( value ) ) {
110
114
prop . mode = propBindingModes . ONE_TIME
111
- } else if ( value . charAt ( 0 ) === '*' ) {
112
- prop . mode = propBindingModes . ONE_TIME
113
- value = value . slice ( 1 )
114
- } else if ( value . charAt ( 0 ) === '@' ) {
115
- value = value . slice ( 1 )
116
- if ( settablePathRE . test ( value ) ) {
117
- prop . mode = propBindingModes . TWO_WAY
118
- } else {
119
- process . env . NODE_ENV !== 'production' && _ . warn (
120
- 'Cannot bind two-way prop with non-settable ' +
121
- 'parent path: ' + value
122
- )
115
+ } else {
116
+ prop . dynamic = true
117
+ if ( value . charAt ( 0 ) === '*' ) {
118
+ prop . mode = propBindingModes . ONE_TIME
119
+ value = value . slice ( 1 ) . trim ( )
120
+ } else if ( value . charAt ( 0 ) === '@' ) {
121
+ value = value . slice ( 1 ) . trim ( )
122
+ if ( settablePathRE . test ( value ) ) {
123
+ prop . mode = propBindingModes . TWO_WAY
124
+ } else {
125
+ process . env . NODE_ENV !== 'production' && _ . warn (
126
+ 'Cannot bind two-way prop with non-settable ' +
127
+ 'parent path: ' + value
128
+ )
129
+ }
123
130
}
124
131
}
125
132
}
126
- prop . dynamic = true
127
133
prop . parentPath = value
128
134
}
129
135
@@ -193,13 +199,18 @@ function makePropsLinkFn (props) {
193
199
} else {
194
200
// literal, cast it and just set once
195
201
var raw = prop . raw
196
- value = options . type === Boolean && raw === ''
197
- ? true
198
- // do not cast emptry string.
199
- // _.toNumber casts empty string to 0.
200
- : raw . trim ( )
201
- ? _ . toBoolean ( _ . toNumber ( raw ) )
202
- : raw
202
+ if ( options . type === Boolean && raw === '' ) {
203
+ value = true
204
+ } else if ( raw . trim ( ) ) {
205
+ value = _ . toBoolean ( _ . toNumber ( raw ) )
206
+ if ( process . env . NODE_ENV !== 'production' &&
207
+ ! prop . bindSyntax &&
208
+ value !== raw ) {
209
+ _ . deprecation . PROP_CASTING ( prop . name , prop . raw )
210
+ }
211
+ } else {
212
+ value = raw
213
+ }
203
214
_ . initProp ( vm , prop , value )
204
215
}
205
216
}
0 commit comments