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

Commit

Permalink
fix(clientsidescripts): make exactBinding more exact
Browse files Browse the repository at this point in the history
See #925
  • Loading branch information
hankduan committed Jun 17, 2014
1 parent 4e1cfe5 commit f9082d0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/clientsidescripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ functions.findBindings = function(binding, exactMatch, using) {
if(dataBinding) {
var bindingName = dataBinding.exp || dataBinding[0].exp || dataBinding;
if (exactMatch) {
var matcher = new RegExp('([^a-zA-Z\\d]|$)' + binding + '([^a-zA-Z\\d]|^)');
var matcher = new RegExp('({|\\s|$|\\|)' + binding + '(}|\\s|^|\\|)');
if (matcher.test(bindingName)) {
matches.push(bindings[i]);
}
Expand Down
13 changes: 12 additions & 1 deletion lib/locators.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,19 @@ ProtractorBy.prototype.binding = function(bindingDescriptor) {
* Find an element by exact binding.
*
* @alias by.exactBinding()
* Same as by.binding() except this does not allow for partial matches
* @view
* <span>{{ person.name }}</span>
* <span ng-bind="person-email"></span>
* <span>{{person_phone|uppercase}}</span>
*
* @example
* expect(element(by.exactBinding('person.name')).isPresent()).toBe(true);
* expect(element(by.exactBinding('person-email')).isPresent()).toBe(true);
* expect(element(by.exactBinding('person')).isPresent()).toBe(false);
* expect(element(by.exactBinding('person_phone')).isPresent()).toBe(true);
* expect(element(by.exactBinding('person_phone|uppercase')).isPresent()).toBe(true);
* expect(element(by.exactBinding('phone')).isPresent()).toBe(false);
*
* @param {string} bindingDescriptor
* @return {{findElementsOverride: findElementsOverride, message: string}}
*/
Expand Down

1 comment on commit f9082d0

@owenmead
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works well. Nice patch @hankduan

Please sign in to comment.