8000 make sure vm.$log() includes props after refactor · nerona/vue@80e956a · GitHub
[go: up one dir, main page]

Skip to content

Commit 80e956a

Browse files
committed
make sure vm.$log() includes props after refactor
1 parent d1788b9 commit 80e956a

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/instance/api/data.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,15 @@ export default function (Vue) {
161161
}
162162
// include computed fields
163163
if (!path) {
164-
for (var key in this.$options.computed) {
164+
var key
165+
for (key in this.$options.computed) {
165166
data[key] = clean(this[key])
166167
}
168+
if (this._props) {
169+
for (key in this._props) {
170+
data[key] = clean(this[key])
171+
}
172+
}
167173
}
168174
console.log(data)
169175
}

test/unit/specs/api/data_spec.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@ var nextTick = _.nextTick
55
describe('Data API', function () {
66
var vm
77
beforeEach(function () {
8+
var el = document.createElement('div')
9+
el.setAttribute('prop', 'hi')
810
vm = new Vue({
11+
el: el,
12+
props: ['prop'],
913
data: {
1014
a: 1,
1115
b: {
@@ -150,6 +154,7 @@ describe('Data API', function () {
150154
expect(val.a).toBe(1)
151155
expect(val.b.c).toBe(2)
152156
expect(val.d).toBe(2)
157+
expect(val.prop).toBe('hi')
153158
spy()
154159
}
155160
vm.$log()

0 commit comments

Comments
 (0)
0