Skip to content

Commit 67b14d7

Browse files
author
Evgeny
committed
Simplified get-all-properties to not get constructor, prototype props
1 parent 2ffa613 commit 67b14d7

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

vue-dd/demo/App.vue

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ class LoginRegisterPresenter extends MessagesPresenter {
4343
static test = 2
4444
static test2 = 2
4545
46+
auth = new Auth()
47+
4648
static testF () {
4749
return 1
4850
}
@@ -58,6 +60,8 @@ class LoginRegisterPresenter extends MessagesPresenter {
5860
5961
//
6062
get viewTest () {
63+
this.auth.test = 2
64+
console.log('yo')
6165
return 'test'
6266
}
6367

vue-dd/src/NodeComplex.vue

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -461,14 +461,17 @@ export default {
461461
let proto = Object.getPrototypeOf(modelValue)
462462
463463
let props = []
464+
// Exclude these properties from parent prototypes properties list
465+
const excludeProto = ['caller', 'callee', 'arguments', 'prototype','constructor']
464466
while(proto && proto.constructor.name !== 'Object') {
465-
props.push.apply(props, Object.getOwnPropertyNames(proto).filter(el => !['caller', 'callee', 'arguments'].includes(el)))
467+
props.push.apply(props, Object.getOwnPropertyNames(proto).filter(el => !excludeProto.includes(el)))
466468
proto = Object.getPrototypeOf(proto.constructor.prototype)
467469
}
468470
471+
const exclude = ['prototype'] // Exclude prototype from the root level
469472
let keys = Array.from(
470473
new Set(
471-
Object.getOwnPropertyNames(modelValue).concat(props)
474+
Object.getOwnPropertyNames(modelValue).filter(el => !exclude.includes(el)).concat(props)
472475
)
473476
)
474477

0 commit comments

Comments
 (0)