File tree Expand file tree Collapse file tree 3 files changed +22
-11
lines changed Expand file tree Collapse file tree 3 files changed +22
-11
lines changed Original file line number Diff line number Diff line change @@ -94,11 +94,6 @@ export default function (Vue) {
94
94
// it will be filled up in _initScope().
95
95
this . _data = { }
96
96
97
- // save raw constructor data before merge
98
- // so that we know which properties are provided at
99
- // instantiation.
100
- this . _runtimeData = options . data
101
-
102
97
// call init hook
103
98
this . _callHook ( 'init' )
104
99
Original file line number Diff line number Diff line change @@ -87,11 +87,6 @@ export default function (Vue) {
87
87
)
88
88
}
89
89
var props = this . _props
90
- var runtimeData = this . _runtimeData
91
- ? typeof this . _runtimeData === 'function'
92
- ? this . _runtimeData ( )
93
- : this . _runtimeData
94
- : null
95
90
// proxy data on instance
96
91
var keys = Object . keys ( data )
97
92
var i , key
@@ -104,7 +99,7 @@ export default function (Vue) {
104
99
// template prop present
105
100
if (
106
101
! props || ! hasOwn ( props , key ) ||
107
- ( runtimeData && hasOwn ( runtimeData , key ) && props [ key ] . raw === null )
102
+ ( data && hasOwn ( data , key ) && props [ key ] . raw === null )
108
103
) {
109
104
this . _proxy ( key )
110
105
} else if ( process . env . NODE_ENV !== 'production' ) {
Original file line number Diff line number Diff line change @@ -9,6 +9,27 @@ describe('Instance state initialization', function () {
9
9
expect ( 'should return an object' ) . toHaveBeenWarned ( )
10
10
} )
11
11
12
+ it ( 'should initialize data once per strat' , function ( ) {
13
+ var spyOncePerStrat = jasmine . createSpy ( 'called once per strat' )
14
+ const VM = Vue . extend ( {
15
+ data : function ( ) {
16
+ spyOncePerStrat ( )
17
+ return {
18
+ result : 'false'
19
+ }
20
+ }
21
+ } )
22
+ new VM ( {
23
+ data : function ( ) {
24
+ spyOncePerStrat ( )
25
+ return {
26
+ result : 'true'
27
+ }
28
+ }
29
+ } )
30
+ expect ( spyOncePerStrat . calls . count ( ) ) . toBe ( 2 )
31
+ } )
32
+
12
33
describe ( 'data proxy' , function ( ) {
13
34
var data = {
14
35
a : 0 ,
You can’t perform that action at this time.
0 commit comments