Skip to content

Commit

Permalink
fix: Revert native contains property
Browse files Browse the repository at this point in the history
The change done in this PR: san650#466 caused a regression.

$.text() can find the text in `visibility: hidden` or `display: none` elements.

element.innerText does not return the text. 

Fixes: san650#514
  • Loading branch information
Alonski authored Oct 3, 2021
1 parent 16007bb commit 1125547
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions addon-test-support/properties/contains.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { assign } from '../-private/helpers';
import { findMany, findOne } from '../extend';
import { A } from '@ember/array';
import { assign, every } from '../-private/helpers';
import { findElementWithAssert } from '../extend';

/**
* Returns a boolean representing whether an element or a set of elements contains the specified text.
Expand Down Expand Up @@ -69,7 +68,6 @@ import { A } from '@ember/array';
*
* const page = create({
* scope: '.scope',
* spanContains: contains('span')
* });
*
Expand All @@ -96,13 +94,13 @@ export function contains(selector, userOptions = {}) {

get(key) {
return function(textToSearch) {
let options = assign({
pageObjectKey: `${key}("${textToSearch}")`
}, userOptions);
let options = assign({ pageObjectKey: `${key}("${textToSearch}")` }, userOptions);

let elements = options.multiple ? findMany(this, selector, options) : [findOne(this, selector, options)];
let elements = findElementWithAssert(this, selector, options);

return A(elements).every((element) => element.innerText.indexOf(textToSearch) >= 0);
return every(elements, function(element) {
return element.text().indexOf(textToSearch) >= 0;
});
};
}
};
Expand Down

0 comments on commit 1125547

Please sign in to comment.