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

Filter not recognized when filtered expression contains a '/' with () #4838

Closed
tals opened this issue Feb 2, 2017 · 4 comments
Closed

Filter not recognized when filtered expression contains a '/' with () #4838

tals opened this issue Feb 2, 2017 · 4 comments
Labels

Comments

@tals
Copy link

tals commented Feb 2, 2017

Vue.js version

2.1.10

Reproduction Link

A variation on #4415
https://jsbin.com/heguyujupu/edit?html,console,output

Steps to reproduce

{{ (price) / 100 | currency }}

What is Expected?

This divided number gets filtered

What is actually happening?

Get this error:

[Vue warn]: Property or method \"currency\" is not defined on the instance but referenced during render. Make sure to declare reactive data properties in the data option. 
(found in root instance)"
@rixlabs
Copy link
Contributor

rixlabs commented Feb 2, 2017

The parser think is a regex due to this check

(!p || !/[\w$]/.test(p))
line 58 of filter-parser.js

If you test it with the close parenthesis ')' it gives true.

I can add another 'if' and open a PR. If anyone see a better way just let me know

@tals
Copy link
Author

tals commented Feb 3, 2017

Thanks for the quick response!

Seems like data[0] / 1 and 1. / 2 will blow up for the same reason. Might be worth rolling that into your PR.

@rixlabs
Copy link
Contributor

rixlabs commented Feb 3, 2017

you're right I have to check all the parenthesis and the point. Is not the case for comma if I'm not wrong

@rixlabs
Copy link
Contributor

rixlabs commented Feb 3, 2017

Added dot and square brackets verification

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

No branches or pull requests

3 participants