File tree Expand file tree Collapse file tree 3 files changed +24
-2
lines changed
test/unit/specs/directives Expand file tree Collapse file tree 3 files changed +24
-2
lines changed Original file line number Diff line number Diff line change 11var _ = require ( '../util' )
22var Watcher = require ( '../watcher' )
3+ var identRE = require ( '../parsers/path' ) . identRE
34
45module . exports = {
56
@@ -10,6 +11,13 @@ module.exports = {
1011 var childKey = this . arg
1112 var parentKey = this . expression
1213
14+ if ( ! identRE . test ( childKey ) ) {
15+ _ . warn (
16+ 'Invalid prop key: "' + childKey + '". Prop keys ' +
17+ 'must be valid identifiers.'
18+ )
19+ }
20+
1321 // simple lock to avoid circular updates.
1422 // without this it would stabilize too, but this makes
1523 // sure it doesn't cause other watchers to re-evaluate.
@@ -28,7 +36,8 @@ module.exports = {
2836 function ( val ) {
2937 if ( ! locked ) {
3038 lock ( )
31- child . $set ( childKey , val )
39+ // all props have been initialized already
40+ child [ childKey ] = val
3241 }
3342 }
3443 )
Original file line number Diff line number Diff line change 11var _ = require ( '../util' )
22var Cache = require ( '../cache' )
33var pathCache = new Cache ( 1000 )
4- var identRE = / ^ [ $ _ a - z A - Z ] + [ \w $ ] * $ /
4+ var identRE = exports . identRE = / ^ [ $ _ a - z A - Z ] + [ \w $ ] * $ /
55
66/**
77 * Path-parsing algorithm scooped from Polymer/observe-js
Original file line number Diff line number Diff line change @@ -58,6 +58,19 @@ if (_.inBrowser) {
5858 } )
5959 } )
6060
61+ it ( 'warn invalid keys' , function ( ) {
62+ var vm = new Vue ( {
63+ el : el ,
64+ template : '<test a.b.c="{{test}}"></test>' ,
65+ components : {
66+ test : {
67+ props : [ 'a.b.c' ]
68+ }
69+ }
70+ } )
71+ expect ( hasWarned ( _ , 'Invalid prop key' ) )
72+ } )
73+
6174 it ( 'teardown' , function ( done ) {
6275 var vm = new Vue ( {
6376 el : el ,
You can’t perform that action at this time.
0 commit comments