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 1
1
var _ = require ( '../util' )
2
2
var Watcher = require ( '../watcher' )
3
+ var identRE = require ( '../parsers/path' ) . identRE
3
4
4
5
module . exports = {
5
6
@@ -10,6 +11,13 @@ module.exports = {
10
11
var childKey = this . arg
11
12
var parentKey = this . expression
12
13
14
+ if ( ! identRE . test ( childKey ) ) {
15
+ _ . warn (
16
+ 'Invalid prop key: "' + childKey + '". Prop keys ' +
17
+ 'must be valid identifiers.'
18
+ )
19
+ }
20
+
13
21
// simple lock to avoid circular updates.
14
22
// without this it would stabilize too, but this makes
15
23
// sure it doesn't cause other watchers to re-evaluate.
@@ -28,7 +36,8 @@ module.exports = {
28
36
function ( val ) {
29
37
if ( ! locked ) {
30
38
lock ( )
31
- child . $set ( childKey , val )
39
+ // all props have been initialized already
40
+ child [ childKey ] = val
32
41
}
33
42
}
34
43
)
Original file line number Diff line number Diff line change 1
1
var _ = require ( '../util' )
2
2
var Cache = require ( '../cache' )
3
3
var pathCache = new Cache ( 1000 )
4
- var identRE = / ^ [ $ _ a - z A - Z ] + [ \w $ ] * $ /
4
+ var identRE = exports . identRE = / ^ [ $ _ a - z A - Z ] + [ \w $ ] * $ /
5
5
6
6
/**
7
7
* Path-parsing algorithm scooped from Polymer/observe-js
Original file line number Diff line number Diff line change @@ -58,6 +58,19 @@ if (_.inBrowser) {
58
58
} )
59
59
} )
60
60
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
+
61
74
it ( 'teardown' , function ( done ) {
62
75
var vm = new Vue ( {
63
76
el : el ,
You can’t perform that action at this time.
0 commit comments