Skip to content

Commit 72d1510

Browse files
committed
include computed properties in vm.$log() (close #1251)
1 parent d681464 commit 72d1510

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/api/data.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,5 +150,11 @@ exports.$log = function (path) {
150150
if (data) {
151151
data = JSON.parse(JSON.stringify(data))
152152
}
153+
// include computed fields
154+
if (!path) {
155+
for (var key in this.$options.computed) {
156+
data[key] = this[key]
157+
}
158+
}
153159
console.log(data)
154160
}

test/unit/specs/api/data_spec.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ describe('Data API', function () {
1818
double: function (v) {
1919
return v * 2
2020
}
21+
},
22+
computed: {
23+
d: function () {
24+
return this.a + 1
25+
}
2126
}
2227
})
2328
})
@@ -161,6 +166,7 @@ describe('Data API', function () {
161166
console.log = function (val) {
162167
expect(val.a).toBe(1)
163168
expect(val.b.c).toBe(2)
169+
expect(val.d).toBe(2)
164170
spy()
165171
}
166172
vm.$log()

0 commit comments

Comments
 (0)