-
Notifications
You must be signed in to change notification settings - Fork 2.3k
feat(locators): Add By.exactBinding locator #812
Conversation
LGTM! |
feat(locators): Add By.exactBinding locator
matches.push(bindings[i]); | ||
if (exactMatch) { | ||
var matcher = new RegExp('([^a-zA-Z\d]|$)' + binding + '([^a-zA-Z\d]|^)'); | ||
if (matcher.test(bindingName)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There seems to be an issue regarding the regex. When running npm test
I get the error:
lib/clientsidescripts.js: line 54, col 45, Bad or unnecessary escaping.
I think it should be changed to:
new RegExp('([^a-zA-Z\\d]|$)' + binding + '([^a-zA-Z\\d]|^)');
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for letting me know. Currently the code works fine with the Regex object, but fails jshint. I'll make that change.
@edconolly Do you have a test case where the regex doesn't capture a brace binding name i.e.{{myBinding}}? It's been working for the tests I've ran, so if you can give me a counterexample, it would be much appreciated. Using 'bindingName.replace(/{|}||.*/g, '') === binding' would not cover cases like |
Apologies I provided an out of date version from which I had locally. This statement is better: .replace(/{|}|\s||.*/g, '') although the Fruit / list example (although I’m not sure if bindings get returned like that) would still not match A test case where the regex match fails is for {{myBinding.notThisVar}}, the regex will match '{myBinding.’ and return that value. Either way I think it would be good to pad out the tests to cover some of these edge cases. From: Hank Duan <[email protected]mailto:[email protected]> @edconollyhttps://github.com/edconolly Do you have a test case where the regex doesn't capture a brace binding name i.e.{{myBinding}}? It's been working for the tests I've ran, so if you can give me a counterexample, it would be much appreciated. Using 'bindingName.replace(/{|}||.*/g, '') === binding' would not cover cases like — WDFC UK Limited. Registered in England & Wales with registered number 6374235 and registered office 88 Crawford Street, London W1H 2EJ. Authorised and regulated by the Financial Conduct Authority. Interim Permission Number 611974. Any communication sent by or on behalf of WDFC UK Limited or any of its subsidiary, holding or affiliated companies or entities (together "Wonga") is confidential and may be privileged or otherwise protected. If you receive it in error please inform us and then delete it from your system. You should not copy it or disclose its contents to anyone. Messages sent to and from Wonga may be monitored to ensure compliance with our internal policies and to protect our business. Emails are not secure and cannot be guaranteed to be error free. Anyone who communicates with us by email is taken to accept these risks.This email has been scanned for email related threats and delivered safely by Mimecast. For more information please visit http://www.mimecast.com |
@edconolly it was a conscience decision to match myBinding in {{myBinding.notThisVar}}. This way you can match either myBinding or myBinding.notThisVar (but not partials of those). |
How is For example, with the following template:
I want to ensure that both |
use by.exactBinding('total.amount') and by.exactBinding('total.tax') to find your binding. If you have an example like this:
by.binding('foo') would match both, whereas by.exactBinding('foo') would only find the second binding |
No description provided.