Fix CSS injection order (#12265) (#12353)

This commit is contained in:
Michael S. Molina
2021-01-08 16:08:34 -03:00
committed by GitHub
parent 737e6b4aee
commit 76b06b215f

View File

@@ -25,11 +25,24 @@ export default function injectCustomCss(css) {
style = document.createElement('style');
style.className = className;
style.type = 'text/css';
head.appendChild(style);
}
if (style.styleSheet) {
style.styleSheet.cssText = css;
} else {
style.innerHTML = css;
}
/**
* Ensures that the style applied is always the last.
*
* from: https://developer.mozilla.org/en-US/docs/Web/API/Node/appendChild
* The Node.appendChild() method adds a node to the end of the list of children
* of a specified parent node. If the given child is a reference to an existing
* node in the document, appendChild() moves it from its current position to the
* new position (there is no requirement to remove the node from its parent node
* before appending it to some other node).
*/
head.appendChild(style);
}