Skip to content

Commit

Permalink
introduce element.containsText
Browse files Browse the repository at this point in the history
  • Loading branch information
ro0gr committed Oct 15, 2023
1 parent bdbdb6f commit 735c79d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
3 changes: 3 additions & 0 deletions addon/src/-private/element.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,6 @@ export function text(element) {
return element.textContent;
}

export function containsText(element, searchText) {
return text(element).indexOf(searchText) > -1;
}
8 changes: 4 additions & 4 deletions addon/src/properties/contains.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { $ } from '../-private/jquery';
import { containsText } from '../-private/element';
import { findOne } from '../-private/finders';
import { getter } from '../macros/index';

Expand Down Expand Up @@ -69,9 +69,9 @@ export function contains(selector, userOptions = {}) {
...userOptions,
};

return (
$(findOne(this, selector, options)).text().indexOf(textToSearch) > -1
);
const element = findOne(this, selector, options);

return containsText(element, textToSearch);
};
});
}

0 comments on commit 735c79d

Please sign in to comment.