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

Commit f9082d0

Browse files
committed
fix(clientsidescripts): make exactBinding more exact
See #925
1 parent 4e1cfe5 commit f9082d0

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

lib/clientsidescripts.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ functions.findBindings = function(binding, exactMatch, using) {
5353
if(dataBinding) {
5454
var bindingName = dataBinding.exp || dataBinding[0].exp || dataBinding;
5555
if (exactMatch) {
56-
var matcher = new RegExp('([^a-zA-Z\\d]|$)' + binding + '([^a-zA-Z\\d]|^)');
56+
var matcher = new RegExp('({|\\s|$|\\|)' + binding + '(}|\\s|^|\\|)');
5757
if (matcher.test(bindingName)) {
5858
matches.push(bindings[i]);
5959
}

lib/locators.js

+12-1
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,19 @@ ProtractorBy.prototype.binding = function(bindingDescriptor) {
103103
* Find an element by exact binding.
104104
*
105105
* @alias by.exactBinding()
106-
* Same as by.binding() except this does not allow for partial matches
106+
* @view
107+
* <span>{{ person.name }}</span>
108+
* <span ng-bind="person-email"></span>
109+
* <span>{{person_phone|uppercase}}</span>
107110
*
111+
* @example
112+
* expect(element(by.exactBinding('person.name')).isPresent()).toBe(true);
113+
* expect(element(by.exactBinding('person-email')).isPresent()).toBe(true);
114+
* expect(element(by.exactBinding('person')).isPresent()).toBe(false);
115+
* expect(element(by.exactBinding('person_phone')).isPresent()).toBe(true);
116+
* expect(element(by.exactBinding('person_phone|uppercase')).isPresent()).toBe(true);
117+
* expect(element(by.exactBinding('phone')).isPresent()).toBe(false);
118+
*
108119
* @param {string} bindingDescriptor
109120
* @return {{findElementsOverride: findElementsOverride, message: string}}
110121
*/

0 commit comments

Comments
 (0)