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

fix(clientsidescripts): make exactBinding more exact #940

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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