Skip to content

Commit

Permalink
fix(clientsidescripts): make exactBinding more exact
Browse files Browse the repository at this point in the history
  • Loading branch information
hankduan committed Jun 17, 2014
1 parent a69fe83 commit e13ebd6
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

0 comments on commit e13ebd6

Please sign in to comment.