File tree Expand file tree Collapse file tree 2 files changed +29
-3
lines changed
test/unit/specs/directives Expand file tree Collapse file tree 2 files changed +29
-3
lines changed Original file line number Diff line number Diff line change @@ -31,8 +31,8 @@ exports._initData = function () {
31
31
i = props . length
32
32
while ( i -- ) {
33
33
key = _ . camelize ( props [ i ] )
34
- if ( ! ( key in data ) ) {
35
- data [ key ] = null
34
+ if ( ! ( key in data ) && key !== '$data' ) {
35
+ data [ key ] = undefined
36
36
}
37
37
}
38
38
}
@@ -65,7 +65,9 @@ exports._setData = function (newData) {
65
65
i = props . length
66
66
while ( i -- ) {
67
67
key = props [ i ]
68
- newData . $set ( key , oldData [ key ] )
68
+ if ( key !== '$data' ) {
69
+ newData . $set ( key , oldData [ key ] )
70
+ }
69
71
}
70
72
}
71
73
// unproxy keys not present in new data
Original file line number Diff line number Diff line change @@ -58,6 +58,30 @@ if (_.inBrowser) {
58
58
} )
59
59
} )
60
60
61
+ it ( '$data as prop' , function ( done ) {
62
+ var vm = new Vue ( {
63
+ el : el ,
64
+ template : '<test $data="{{ok}}"></test>' ,
65
+ data : {
66
+ ok : {
67
+ msg : 'hihi'
68
+ }
69
+ } ,
70
+ components : {
71
+ test : {
72
+ props : [ '$data' ] ,
73
+ template : '{{msg}}'
74
+ }
75
+ }
76
+ } )
77
+ expect ( el . innerHTML ) . toBe ( '<test>hihi</test>' )
78
+ vm . ok = { msg : 'what' }
79
+ _ . nextTick ( function ( ) {
80
+ expect ( el . innerHTML ) . toBe ( '<test>what</test>' )
81
+ done ( )
82
+ } )
83
+ } )
84
+
61
85
it ( 'warn invalid keys' , function ( ) {
62
86
var vm = new Vue ( {
63
87
el : el ,
You can’t perform that action at this time.
0 commit comments