-
Notifications
You must be signed in to change notification settings - Fork 20.5k
Handle the case of an empty string. Fixes #13401 #1162
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
Conversation
src/manipulation.js
Outdated
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 not elem === "" instead?
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 test also handles the case of " ", which wouldn't work with elem === ""
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.
... but would have been caught by elem since !!" " === true.
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.
elem === "" should work as well.
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.
-3 bytes by changing this condition to elem != null && elem !== false.
|
I approve of this pull, but it changes the behavior of other manipulation methods ( |
|
From this perspective I totally agree that the change causes more harm than good. I prefer to have a lean |
|
@markraddatz Do you want to submit another pull request with that approach? I'd suggest keeping the |
|
I submitted a new pull request that skips |
|
Closing in favor of gh-1163. |
This will fix .replaceWith() when you pass an empty string.