In the early stages of JavaScript it was not possible to remove an element directly. Was necessary:
```
element.parentNode.removeChild(element);
```
Later a direct function was added:
```
element.remove();
```
All browsers [[ https://www.w3schools.com/jsref/met_element_remove.asp | have added support for this function ]], except Internet Explorer. Now that Internet Explorer is no longer supported and the minimum JavaScript version is ES6, I believe MediaWiki should be updated. It makes the code smaller and more direct.
In a direct search of the MediaWiki source code:
https://codesearch.wmcloud.org/search/?q=removeChild
We see that several scripts use the older, longer method, as an example:
https://gerrit.wikimedia.org/g/mediawiki/core/+/dfd748033e5ab7272ef52f5b5425c28a35e0cbec/resources/lib/vue/vue.global.js#9635
Which is:
```
remove: (child) => {
const parent = child.parentNode;
if (parent) {
parent.removeChild(child);
}
}
```
But it can be simplified to:
```
remove: (child) => {
child.remove();
}
```
The original if statement was used to check if the child element was actually part of the DOM before attempting to remove it. This was done to avoid potential errors in case the child element was not connected to any parent node.
However, with the introduction of the modern remove() method, this if statement is no longer strictly necessary. The remove() method is designed to handle situations where the element is not part of the DOM gracefully. It simply does nothing if the element is not found or is already detached.