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) {
9494 // it will be filled up in _initScope().
9595 this . _data = { }
9696
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-
10297 // call init hook
10398 this . _callHook ( 'init' )
10499
Original file line number Diff line number Diff line change @@ -87,11 +87,6 @@ export default function (Vue) {
8787 )
8888 }
8989 var props = this . _props
90- var runtimeData = this . _runtimeData
91- ? typeof this . _runtimeData === 'function'
92- ? this . _runtimeData ( )
93- : this . _runtimeData
94- : null
9590 // proxy data on instance
9691 var keys = Object . keys ( data )
9792 var i , key
@@ -104,7 +99,7 @@ export default function (Vue) {
10499 // template prop present
105100 if (
106101 ! props || ! hasOwn ( props , key ) ||
107- ( runtimeData && hasOwn ( runtimeData , key ) && props [ key ] . raw === null )
102+ ( data && hasOwn ( data , key ) && props [ key ] . raw === null )
108103 ) {
109104 this . _proxy ( key )
110105 } 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 () {
99 expect ( 'should return an object' ) . toHaveBeenWarned ( )
1010 } )
1111
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+
1233 describe ( 'data proxy' , function ( ) {
1334 var data = {
1435 a : 0 ,
You can’t perform that action at this time.
0 commit comments