Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
The boolean comparison will certainly be faster than the string comparison. It would be preferable to do the boolean check first.
I would also move the
removeChildren
check in theVNodeType.Element
case since slots can only be elements.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.
We have a lint rule: no-case-declarations that prevents us from doing that.
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.
I assumed that the property lookup (
vnode.owner.shadowMode
) would be more expensive than a string comparison. I have no idea what the perf difference is, but it's probably a micro-optimization either way.As Sattar said, yeah, we have to keep the
removeChildren
where it is unfortunately.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.
Aren't rules made to be broken? 🤣
More seriously, this ESLint rule prevents declaration in
switch
to avoid re-declaration. By default, variables are declared at the switch level and not at the case level (detail). The way to work around this is to create a new block scope forcase
s with variable declarations.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.
Added a case block.