File tree Expand file tree Collapse file tree 2 files changed +25
-4
lines changed Expand file tree Collapse file tree 2 files changed +25
-4
lines changed Original file line number Diff line number Diff line change 6
6
</template >
7
7
8
8
<script >
9
+ // this computed property should be visible
10
+ // even if component has no 'computed' defined
11
+ const computedPropMixin = {
12
+ computed: {
13
+ computedPropFromMixin () {
14
+ return null
15
+ }
16
+ }
17
+ }
18
+
9
19
export default {
10
20
props: [' id' ],
21
+ mixins: [ computedPropMixin ],
11
22
data () {
12
23
let a = { c : function () {} }
13
24
a .a = a
Original file line number Diff line number Diff line change @@ -429,23 +429,33 @@ function processState (instance) {
429
429
*/
430
430
431
431
function processComputed ( instance ) {
432
- return Object . keys ( instance . $options . computed || { } ) . map ( key => {
432
+ const computed = [ ]
433
+ // use for...in here because if 'computed' is not defined
434
+ // on component, computed properties will be placed in prototype
435
+ // and Object.keys does not include
436
+ // properties from object's prototype
437
+ for ( const key in ( instance . $options . computed || { } ) ) {
433
438
// use try ... catch here because some computed properties may
434
439
// throw error during its evaluation
440
+ let computedProp = null
435
441
try {
436
- return {
442
+ computedProp = {
437
443
type : 'computed' ,
438
444
key,
439
445
value : instance [ key ]
440
446
}
441
447
} catch ( e ) {
442
- return {
448
+ computedProp = {
443
449
type : 'computed' ,
444
450
key,
445
451
value : '(error during evaluation)'
446
452
}
447
453
}
448
- } )
454
+
455
+ computed . push ( computedProp )
456
+ }
457
+
458
+ return computed
449
459
}
450
460
451
461
/**
You can’t perform that action at this time.
0 commit comments