Skip to content

Commit 47bb792

Browse files
committed
do not use class for now
1 parent bc4b7bb commit 47bb792

File tree

2 files changed

+19
-14
lines changed

2 files changed

+19
-14
lines changed

src/instance/internal/state.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,23 @@ import {
1717

1818
export default function (Vue) {
1919

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+
2037
/**
2138
* Setup the scope of an instance, which contains:
2239
* - observed data

src/instance/vue.js

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,8 @@ import lifecycleAPI from './api/lifecycle'
2424
* @public
2525
*/
2626

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)
4129
}
4230

4331
// install internals

0 commit comments

Comments
 (0)