8000 refactor: move deepProxy into utils. · rubythonode/nativescript-vue@dfa5997 · GitHub
[go: up one dir, main page]

Skip to content

Commit dfa5997

Browse files
committed
refactor: move deepProxy into utils.
1 parent fb1d8c6 commit dfa5997

File tree

2 files changed

+17
-14
lines changed

2 files changed

+17
-14
lines changed

platform/nativescript/runtime/components/v-template.js

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { patch } from '../patch'
2+
import { deepProxy } from '../../util'
23

34
export const VUE_VIEW = '__vueVNodeRef__'
45

@@ -52,9 +53,11 @@ export class TemplateBag {
5253
let curr
5354
while ((curr = iterator.next().value)) {
5455
const [name, { conditionFn }] = curr
55-
if (conditionFn(item)) {
56-
return name
57-
}
56+
try {
57+
if (conditionFn(item)) {
58+
return name
59+
}
60+
} catch (err) {}
5861
}
5962
return 'default'
6063
}
@@ -104,14 +107,3 @@ export class VueKeyedTemplate /* implements KeyedTemplate */ {
104107
return nativeView
105108
}
106109
}
107-
108-
function deepProxy(object, depth = 0) {
109-
return new Proxy(object, {
110-
get() {
111-
if (depth > 10) {
112-
throw new Error('deepProxy over 10 deep.')
113-
}
114-
return deepProxy({}, depth + 1)
115-
}
116-
})
117-
}

platform/nativescript/util/index.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,14 @@ export function after(original, thisArg, wrap) {
5757
original.apply(thisArg, args)
5858
}
5959
}
60+
61+
export function deepProxy(object, depth = 0) {
62+
return new Proxy(object, {
63+
get() {
64+
if (depth > 10) {
65+
throw new Error('deepProxy over 10 deep.')
66+
}
67+
return deepProxy({}, depth + 1)
68+
}
69+
})
70+
}

0 commit comments

Comments
 (0)
0