Skip to content

Commit 7e018d6

Browse files
committed
fix: update isNativeVariable checker
1 parent 1f820e5 commit 7e018d6

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

lib/entity/data.js

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Lexer } from '@/generators/lexer'
22
import { State } from '@/state'
3+
import { isNativeVariable } from '@/helpers/variables'
34

45
const IGNORED_IDS = ['this', '$']
56

@@ -46,11 +47,7 @@ export class Data {
4647
if (attr === 'each') {
4748
const [_, variable] = expr.split(' in ')
4849

49-
const isNativeVariable =
50-
typeof window[variable] === 'function' &&
51-
window[variable].toString().indexOf('[native code]') === -1
52-
53-
if (isNativeVariable) return
50+
if (isNativeVariable(variable)) return
5451
if (IGNORED_IDS.includes(variable)) return
5552
if (variable in this.entity.state) return
5653
this.add(variable, attr)

lib/helpers/variables.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
export const isNativeVariable = (variable) =>
22
typeof window[variable] === 'function' &&
3-
window[variable].toString().indexOf('[native code]') === -1
3+
window[variable].toString().indexOf('[native code]') !== -1

0 commit comments

Comments
 (0)