Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions src/instance/internal/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,6 @@ export default function (Vue) {
// it will be filled up in _initScope().
this._data = {}

// save raw constructor data before merge
// so that we know which properties are provided at
// instantiation.
this._runtimeData = options.data

// call init hook
this._callHook('init')

Expand Down
7 changes: 1 addition & 6 deletions src/instance/internal/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,6 @@ export default function (Vue) {
)
}
var props = this._props
var runtimeData = this._runtimeData
? typeof this._runtimeData === 'function'
? this._runtimeData()
: this._runtimeData
: null
// proxy data on instance
var keys = Object.keys(data)
var i, key
Expand All @@ -104,7 +99,7 @@ export default function (Vue) {
// template prop present
if (
!props || !hasOwn(props, key) ||
(runtimeData && hasOwn(runtimeData, key) && props[key].raw === null)
(data && hasOwn(data, key) && props[key].raw === null)
) {
this._proxy(key)
} else if (process.env.NODE_ENV !== 'production') {
Expand Down
21 changes: 21 additions & 0 deletions test/unit/specs/instance/state_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,27 @@ describe('Instance state initialization', function () {
expect('should return an object').toHaveBeenWarned()
})

it('should initialize data once per strat', function () {
var spyOncePerStrat = jasmine.createSpy('called once per strat')
const VM = Vue.extend({
data: function () {
spyOncePerStrat()
return {
result: 'false'
}
}
})
new VM({
data: function () {
spyOncePerStrat()
return {
result: 'true'
}
}
})
expect(spyOncePerStrat.calls.count()).toBe(2)
})

describe('data proxy', function () {
var data = {
a: 0,
Expand Down