-
Notifications
You must be signed in to change notification settings - Fork 2
feat(dom): DOM - toBeEmpty #162
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
base: main
Are you sure you want to change the base?
Conversation
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.
Awesome work @SbsCruz! The only thing to review is the comment above with the rest of the team. Other than that, it looks great to me! 👍
| } | ||
|
|
||
| export function isElementEmpty (element: Element): boolean { | ||
| const nonCommentChildNodes = [...element.childNodes].filter(child => child.nodeType !== 8); |
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.
Why do we use nodeType != 8. What does 8 represent?
You could refactor this to be a constant based on what it is.
const NODE_TYPE_ABCD _ID = 8;
then you can use the constant so we can avoid hardcoding multiple times this type of data on different scenarios.
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.
number 8 represents the COMMENT_NODE, (as shown here) so they are excluded from the function,
and sure, i will make it a constant so it's more legible, thanks!
suany0805
left a comment
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.
Nice work! just left a couple of comments! Let me know if you would like to pair to review them :)
Added the toBeEmpty matcher.