Skip to content

Commit

Permalink
fix: update isNativeVariable checker
Browse files Browse the repository at this point in the history
  • Loading branch information
jorenrui committed Feb 27, 2024
1 parent 1f820e5 commit 7e018d6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
7 changes: 2 additions & 5 deletions lib/entity/data.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Lexer } from '@/generators/lexer'
import { State } from '@/state'
import { isNativeVariable } from '@/helpers/variables'

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

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

const isNativeVariable =
typeof window[variable] === 'function' &&
window[variable].toString().indexOf('[native code]') === -1

if (isNativeVariable) return
if (isNativeVariable(variable)) return
if (IGNORED_IDS.includes(variable)) return
if (variable in this.entity.state) return
this.add(variable, attr)
Expand Down
2 changes: 1 addition & 1 deletion lib/helpers/variables.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export const isNativeVariable = (variable) =>
typeof window[variable] === 'function' &&
window[variable].toString().indexOf('[native code]') === -1
window[variable].toString().indexOf('[native code]') !== -1

0 comments on commit 7e018d6

Please sign in to comment.