Skip to content
This repository has been archived by the owner on Jul 29, 2024. It is now read-only.

exactBinding isn't so exact #925

Closed
owenmead opened this issue Jun 12, 2014 · 5 comments
Closed

exactBinding isn't so exact #925

owenmead opened this issue Jun 12, 2014 · 5 comments
Milestone

Comments

@owenmead
Copy link
Contributor

Like the idea of exact binding, but my impression is that it would bind exactly

Say I have the following binding:
{{ data_source.model.volts|number:2 }}

I would expect to use either "volts" or the whole binding expression.

Problem is that I also have:
{{ data_source.model.volts_average|number:2 }}

Since exactBinding uses the following regex it matches both volts and volts_average
var matcher = new RegExp('([^a-zA-Z\\d]|$)' + binding + '([^a-zA-Z\\d]|^)');

Thinking the following would make the most sense
by.binding - Using the simple contains search (also doesn't break anything)
by.exactBinding - Matches the whole binding, including the filter etc
by.regExBinding - Pass in a regular expression to match against

Be happy to send a pull request if others think this is a good idea

@juliemr
Copy link
Member

juliemr commented Jun 16, 2014

@hankduan what do you think about including . and _ as characters for exact binding to test against?

@hankduan
Copy link
Contributor

I feel like having three locators for binding is excessive, but even if we include . and _ into by.exactBinding, people can use all sorts of special characters (-,$,@, etc). We can also say exactBinding needs to be exact until whitespace and | too.

var matcher = new RegExp('(\s|$|\|)' + binding + '(\s^|\|)');

@juliemr
Copy link
Member

juliemr commented Jun 17, 2014

+1 for it needing to be exact up until whitespace or a |.

@owenmead
Copy link
Contributor Author

+1 for exact being exact up until the first | It's much easier to explain and document
"Matches binding exactly. Does not include filters as part of match."

My suggestion for the regEx option was to provide a bit more flexibility, but you are probably right that just exact and contains is enough. At least until someone comes up with a use case to need the regEx.

@juliemr juliemr added this to the 1.0 milestone Jun 17, 2014
hankduan added a commit to hankduan/protractor that referenced this issue Jun 17, 2014
hankduan added a commit to hankduan/protractor that referenced this issue Jun 17, 2014
@hankduan
Copy link
Contributor

merged with f9082d0

@hankduan hankduan removed their assignment Nov 4, 2015
bodyduardU pushed a commit to bodyduardU/protractor that referenced this issue Dec 5, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants