-
Notifications
You must be signed in to change notification settings - Fork 32k
Replace removeChild
with remove
#213465
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
Replace removeChild
with remove
#213465
Conversation
911d359
to
5cf9f14
Compare
This replaces most uses of `parent.removeChild(child)` with `child.remove()`. The two are almost equivalent. The only difference is that `parent.removeChild(child)` throws if the given node is not a child of the parent, whereas `child.remove()` never throws. There is no noticable performance difference. The only reason to use `removeChild` is to support Internet Explorer, but that’s no longer supported by Monaco editor.
The script content changed, so the sha256 hash changed too.
6d51dfb
to
277b6e2
Compare
Co-authored-by: Logan Ramos <lramos15@gmail.com>
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.
Thanks for the information and the contribution
@@ -5,7 +5,7 @@ | |||
<meta charset="UTF-8"> | |||
|
|||
<meta http-equiv="Content-Security-Policy" | |||
content="default-src 'none'; script-src 'sha256-bQPwjO6bLiyf6v9eDVtAI67LrfonA1w49aFkRXBy4/g=' 'self'; frame-src 'self'; style-src 'unsafe-inline';"> | |||
content="default-src 'none'; script-src 'sha256-noHVLQsurkONXmA3fcuAmcZ8UPYm/db88mhm9gAXcvk=' 'self'; frame-src 'self'; style-src 'unsafe-inline';"> |
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.
@mjbvz is this change expected?
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.
Looks good, it matches what I computed for the <script> tag at https://emn178.github.io/online-tools/sha256.html

@remcohaszing @lramos15 isnt this a bad change? Notice 4 remove calls after, and 2 before? ![]() Did we review this change throughly? |
Yes, you just beat me to this comment. It’s a sloppy mistake. It happens twice, right before and after that Do you want to go through with the full revert or should I just fix those occurrences? |
This fixes a regression caused by microsoft#213465 Closes microsoft#214303 Closes microsoft#214345
if (defaultStyles.length) { | ||
mainWindow.document.head.removeChild(defaultStyles[0]); | ||
} | ||
defaultStyles?.[0].remove(); |
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.
@remcohaszing this is not a good change, what if the array is empty?
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.
This was indeed wrong. Fixed it in #214348.
catch (error) { | ||
// Ignore, removed already by change of focus | ||
} | ||
this.selectDropDownContainer.remove(); // remove to take out the CSS rules we add |
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.
Could this throw? why was it try/catch before?
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.
No. parent.removeChild(child)
throws if child
is not a child of parent
. child.remove()
never throws. Aside from not needing a reference to the parent, that’s the only difference.
This replaces most uses of
parent.removeChild(child)
withchild.remove()
.The two are almost equivalent. The only difference is that
parent.removeChild(child)
throws if the given node is not a child of the parent, whereaschild.remove()
never throws. There is no noticable performance difference. The only reason to useremoveChild
is to support Internet Explorer, but that’s no longer supported by Monaco editor.I tested this in the Monaco playground, but not very thoroughly.