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

Commit a234942

Browse files
committed
Adding support for ng_repeat, data-ng-repeat, and x-ng-repeat.
1 parent ed5740a commit a234942

File tree

2 files changed

+31
-19
lines changed

2 files changed

+31
-19
lines changed

protractor.js

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,14 @@ clientSideScripts.findBindings = function() {
8080
var index = arguments[1];
8181

8282
var rows = [];
83-
var repeatElems = document.querySelectorAll('[ng-repeat]');
84-
for (var i = 0; i < repeatElems.length; ++i) {
85-
if (repeatElems[i].getAttribute('ng-repeat').indexOf(repeater) != -1) {
86-
rows.push(repeatElems[i]);
83+
var prefixes = ['ng-', 'ng_', 'data-ng-', 'x-ng-'];
84+
for (var p = 0; p < prefixes.length; ++p) {
85+
var attr = prefixes[p] + 'repeat';
86+
var repeatElems = document.querySelectorAll('[' + attr + ']');
87+
for (var i = 0; i < repeatElems.length; ++i) {
88+
if (repeatElems[i].getAttribute(attr).indexOf(repeater) != -1) {
89+
rows.push(repeatElems[i]);
90+
}
8791
}
8892
}
8993
return rows[index - 1];
@@ -105,10 +109,14 @@ clientSideScripts.findRepeaterElement = function() {
105109
var binding = arguments[2];
106110

107111
var rows = [];
108-
var repeatElems = document.querySelectorAll('[ng-repeat]');
109-
for (var i = 0; i < repeatElems.length; ++i) {
110-
if (repeatElems[i].getAttribute('ng-repeat').indexOf(repeater) != -1) {
111-
rows.push(repeatElems[i]);
112+
var prefixes = ['ng-', 'ng_', 'data-ng-', 'x-ng-'];
113+
for (var p = 0; p < prefixes.length; ++p) {
114+
var attr = prefixes[p] + 'repeat';
115+
var repeatElems = document.querySelectorAll('[' + attr + ']');
116+
for (var i = 0; i < repeatElems.length; ++i) {
117+
if (repeatElems[i].getAttribute(attr).indexOf(repeater) != -1) {
118+
rows.push(repeatElems[i]);
119+
}
112120
}
113121
}
114122
var row = rows[index - 1];
@@ -145,10 +153,14 @@ clientSideScripts.findRepeaterElement = function() {
145153
var binding = arguments[1];
146154

147155
var rows = [];
148-
var repeatElems = document.querySelectorAll('[ng-repeat]');
149-
for (var i = 0; i < repeatElems.length; ++i) {
150-
if (repeatElems[i].getAttribute('ng-repeat').indexOf(repeater) != -1) {
151-
rows.push(repeatElems[i]);
156+
var prefixes = ['ng-', 'ng_', 'data-ng-', 'x-ng-'];
157+
for (var p = 0; p < prefixes.length; ++p) {
158+
var attr = prefixes[p] + 'repeat';
159+
var repeatElems = document.querySelectorAll('[' + attr + ']');
160+
for (var i = 0; i < repeatElems.length; ++i) {
161+
if (repeatElems[i].getAttribute(attr).indexOf(repeater) != -1) {
162+
rows.push(repeatElems[i]);
163+
}
152164
}
153165
}
154166
for (var i = 0; i < rows.length; ++i) {

spec/testAppSpec.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ describe('test application', function() {
110110
});
111111
});
112112

113-
xit('should find a repeater using data-ng-repeat', function(done) {
113+
it('should find a repeater using data-ng-repeat', function(done) {
114114
catchPromiseErrors(done);
115115
ptor.findElement(protractor.By.repeater('day in days').row(3)).
116116
getText().then(function(text) {
@@ -139,28 +139,28 @@ describe('test application', function() {
139139
});
140140
});
141141

142-
xit('should find a repeater using ng_repeat', function(done) {
142+
it('should find a repeater using ng_repeat', function(done) {
143143
catchPromiseErrors(done);
144144
ptor.findElement(protractor.By.repeater('foo in days').row(3)).
145145
getText().then(function(text) {
146146
expect(text).toEqual('Wed');
147147
});
148-
ptor.findElement(protractor.By.repeater('foo in days').row(3)).
149-
column('foo').
148+
ptor.findElement(protractor.By.repeater('foo in days').row(3).
149+
column('foo')).
150150
getText().then(function(text) {
151151
expect(text).toEqual('Wed');
152152
done();
153153
});
154154
});
155155

156-
xit('should find a repeater using x-ng-repeat', function(done) {
156+
it('should find a repeater using x-ng-repeat', function(done) {
157157
catchPromiseErrors(done);
158158
ptor.findElement(protractor.By.repeater('qux in days').row(3)).
159159
getText().then(function(text) {
160160
expect(text).toEqual('Wed');
161161
});
162-
ptor.findElement(protractor.By.repeater('qux in days').row(3)).
163-
column('quz').
162+
ptor.findElement(protractor.By.repeater('qux in days').row(3).
163+
column('qux')).
164164
getText().then(function(text) {
165165
expect(text).toEqual('Wed');
166166
done();

0 commit comments

Comments
 (0)