File tree Expand file tree Collapse file tree 2 files changed +19
-14
lines changed Expand file tree Collapse file tree 2 files changed +19
-14
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,23 @@ import {
17
17
18
18
export default function ( Vue ) {
19
19
20
+ /**
21
+ * Accessor for `$data` property, since setting $data
22
+ * requires observing the new object and updating
23
+ * proxied properties.
24
+ */
25
+
26
+ Object . defineProperty ( Vue . prototype , '$data' , {
27
+ get ( ) {
28
+ return this . _data
29
+ } ,
30
+ set ( newData ) {
31
+ if ( newData !== this . _data ) {
32
+ this . _setData ( newData )
33
+ }
34
+ }
35
+ } )
36
+
20
37
/**
21
38
* Setup the scope of an instance, which contains:
22
39
* - observed data
Original file line number Diff line number Diff line change @@ -24,20 +24,8 @@ import lifecycleAPI from './api/lifecycle'
24
24
* @public
25
25
*/
26
26
27
- class Vue {
28
- constructor ( options ) {
29
- this . _init ( options )
30
- }
31
-
32
- get $data ( ) {
33
- return this . _data
34
- }
35
-
36
- set $data ( newData ) {
37
- if ( newData !== this . _data ) {
38
- this . _setData ( newData )
39
- }
40
- }
27
+ function Vue ( options ) {
28
+ this . _init ( options )
41
29
}
42
30
43
31
// install internals
You can’t perform that action at this time.
0 commit comments