Skip to content

Commit

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

export function text(element) {
return element.textContent;
}

4 changes: 2 additions & 2 deletions addon/src/properties/text.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { $ } from '../-private/jquery';
import { findOne } from '../-private/finders';
import { getter } from '../macros/index';
import { text as textContent } from '../-private/element';

function identity(v) {
return v;
Expand Down Expand Up @@ -93,7 +93,7 @@ export function text(selector, userOptions = {}) {
};

let f = options.normalize === false ? identity : normalizeText;
return f($(findOne(this, selector, options)).text());
return f(textContent(findOne(this, selector, options)));
});
}

Expand Down

0 comments on commit bdbdb6f

Please sign in to comment.