@@ -49,16 +49,12 @@ module.exports = function compileProps (el, propOptions) {
4949 attr = _ . hyphenate ( name )
5050 value = el . getAttribute ( attr )
5151
52- if ( value !== null && process . env . NODE_ENV !== 'production' ) {
53- _ . deprecation . PROPS ( attr , value )
54- }
55-
5652 if ( value === null ) {
5753 value = el . getAttribute ( 'data-' + attr )
5854 if ( value !== null ) {
5955 attr = 'data-' + attr
6056 if ( process . env . NODE_ENV !== 'production' ) {
61- _ . deprecation . PROPS ( attr , value )
57+ _ . deprecation . DATA_PROPS ( attr , value )
6258 }
6359 }
6460 }
@@ -77,6 +73,11 @@ module.exports = function compileProps (el, propOptions) {
7773 el . removeAttribute ( attr )
7874 var tokens = textParser . parse ( value )
7975 if ( tokens ) {
76+
77+ if ( process . env . NODE_ENV !== 'production' ) {
78+ _ . deprecation . PROPS ( attr , value )
79+ }
80+
8081 prop . dynamic = true
8182 prop . parentPath = textParser . tokensToExp ( tokens )
8283 // check prop binding type.
@@ -100,30 +101,35 @@ module.exports = function compileProps (el, propOptions) {
100101 }
101102 }
102103 } else {
103- // new prop- syntax
104- attr = 'prop -' + attr
104+ // new syntax
105+ attr = 'bind -' + attr
105106 value = prop . raw = el . getAttribute ( attr )
106107 if ( value !== null ) {
108+ // mark it so we know this is a bind
109+ prop . bindSyntax = true
107110 el . removeAttribute ( attr )
111+ value = value . trim ( )
108112 // check binding type
109113 if ( literalValueRE . test ( value ) ) {
110114 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+ }
123130 }
124131 }
125132 }
126- prop . dynamic = true
127133 prop . parentPath = value
128134 }
129135
@@ -193,13 +199,18 @@ function makePropsLinkFn (props) {
193199 } else {
194200 // literal, cast it and just set once
195201 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+ }
203214 _ . initProp ( vm , prop , value )
204215 }
205216 }
0 commit comments