-
Notifications
You must be signed in to change notification settings - Fork 6.8k
feat(cdk/testing): add optional excludes to TestElement text method #20145
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 5 commits
5f31c05
cbabed5
ce5ad75
21876af
90785d3
a724e5c
d5c2dcd
0a6a599
78fa003
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export function getTextWithExcludedElements(element: Element, excludeSelector: string) { | ||
annieyw marked this conversation as resolved.
Show resolved
Hide resolved
|
||
const clone = element.cloneNode(true) as Element; | ||
const exclusions = clone.querySelectorAll(excludeSelector); | ||
for (let i = 0; i < exclusions.length; i++) { | ||
let child = exclusions[i]; | ||
child.parentNode?.removeChild(child); | ||
} | ||
return (clone.textContent || '').trim(); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On this file name:
😉 How about There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That works as long as its just this function here, but I asked her to move some other DOM related stuff here too There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've renamed it to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Much nicer. While you're at it, can you do the same thing for the other usages of
browser.executeScript
? They're much simpler functions, but would still be nice to have them be typed functions instead of strings