Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could not parse DOM element properties #21

Open
tangshuang opened this issue Mar 5, 2021 · 3 comments
Open

Could not parse DOM element properties #21

tangshuang opened this issue Mar 5, 2021 · 3 comments

Comments

@tangshuang
Copy link

In my case, I give a DOM element to scope, and want to parse out the value property, but not work:

const el = document.querySelector('#input')
const ev = expressions.compile('el.value')
console.log(ev({ el }))

I get undefined, could you please to fix this?

@edi9999
Copy link
Collaborator

edi9999 commented Mar 5, 2021

Hello @tangshuang , I don't have the time to put active work like this on the project because of other priorities.
If you write a pull request, I will look at it.

@edi9999 edi9999 closed this as completed Mar 5, 2021
@edi9999 edi9999 reopened this Mar 5, 2021
@cdelaorden
Copy link

cdelaorden commented Jun 8, 2021

@tangshuang your code is wrong, you need to use the value of the element for the expression, not the string "el.value". That is:

const el = document.querySelector('#input')
const evaluate = expressions.compile(el.value) 
console.log(evaluate({}) // whatever scope you need

This assuming of course the expression is in the input.

EDIT: I understand now that what you want is to evaluate an expression using the element value. If it doesn't work it's probably because it's not enumerable (own property) or something similar. We've noticed many "standard things" do not work as expected inside the angular parser.

@tangshuang
Copy link
Author

tangshuang commented Jun 9, 2021

@cdelaorden you are right, I modified the code, see here https://github.com/tangshuang/scopex/blob/master/index.js (may face secure problem, not sure)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants