From e13ebd6f9ebdc822efdc1ffb28490ef65f27e079 Mon Sep 17 00:00:00 2001 From: Hank Duan Date: Tue, 17 Jun 2014 12:31:00 -0700 Subject: [PATCH] fix(clientsidescripts): make exactBinding more exact See https://github.com/angular/protractor/issues/925 --- lib/clientsidescripts.js | 2 +- lib/locators.js | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/clientsidescripts.js b/lib/clientsidescripts.js index bf328048b..8cd771c19 100644 --- a/lib/clientsidescripts.js +++ b/lib/clientsidescripts.js @@ -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]); } diff --git a/lib/locators.js b/lib/locators.js index 6553e4515..4c3c7e442 100644 --- a/lib/locators.js +++ b/lib/locators.js @@ -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 + * {{ person.name }} + * + * {{person_phone|uppercase}} * + * @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}} */