Skip to content

Change element.parentNode.removeChild(element) to element.remove()#34071

Merged
XhmikosR merged 4 commits into
mainfrom
gs-add-remove-element-helper
May 25, 2021
Merged

Change element.parentNode.removeChild(element) to element.remove()#34071
XhmikosR merged 4 commits into
mainfrom
gs-add-remove-element-helper

Conversation

@GeoSot

@GeoSot GeoSot commented May 22, 2021

Copy link
Copy Markdown
Member

Change element.parentNode.removeChild(element) to element.remove()

@GeoSot GeoSot marked this pull request as ready for review May 22, 2021 00:10
@GeoSot GeoSot requested a review from a team as a code owner May 22, 2021 00:10
@XhmikosR XhmikosR changed the title Make removeElement helper Add removeElement helper May 22, 2021
@alpadev

alpadev commented May 22, 2021

Copy link
Copy Markdown
Contributor

Hm instead of using parentNode.removeChild() what if we just use element.remove()? This wouldn't throw if a parent doesn't exist, but serves the same functionality.

@XhmikosR

XhmikosR commented May 22, 2021

Copy link
Copy Markdown
Member

I actually planned to switch to modern APIs but never got to finish the branch and I can't find it right now.

bootstrap/.eslintrc.json

Lines 51 to 53 in b39b665

"unicorn/prefer-dom-node-append": "off",
"unicorn/prefer-dom-node-dataset": "off",
"unicorn/prefer-dom-node-remove": "off",

And so on. :) I'd leave this for a separate PR, though.

Comment thread js/tests/unit/util/index.spec.js Outdated
@GeoSot GeoSot force-pushed the gs-add-remove-element-helper branch 2 times, most recently from efc5a90 to 1fc3957 Compare May 24, 2021 14:42
@GeoSot GeoSot force-pushed the gs-add-remove-element-helper branch from 1fc3957 to e8d2e64 Compare May 25, 2021 11:50
@GeoSot GeoSot changed the title Add removeElement helper Change element.remove() method May 25, 2021
@XhmikosR XhmikosR changed the title Change element.remove() method Change element.parentNode.removeChild(element) to element.remove() May 25, 2021
@XhmikosR XhmikosR merged commit 544d9ac into main May 25, 2021
@XhmikosR XhmikosR deleted the gs-add-remove-element-helper branch May 25, 2021 15:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants