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 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(); }