UNPKG

927 BJavaScriptView Raw
1exports.moveStyles = function () {
2 if (
3 typeof document === 'undefined' ||
4 !document.body ||
5 !document.head) {
6 return;
7 }
8 // move all injects style tags to the <head/>
9 var linkTags = document.querySelectorAll('[data-used-styles]');
10 var root = document.head.firstChild;
11 // remove in two steps to prevent flickering
12 for (var i = 0; i < linkTags.length; ++i) {
13 document.head.insertBefore(linkTags[i].cloneNode(true), root);
14 }
15 for (var i = 0; i < linkTags.length; ++i) {
16 linkTags[i].parentNode.removeChild(linkTags[i]);
17 }
18};
19
20exports.removeStyles = function () {
21 if (
22 typeof document === 'undefined' ||
23 !document.body ||
24 !document.head) {
25 return;
26 }
27 // move all injects style tags to the <head/>
28 var linkTags = document.querySelectorAll('[data-used-styles]');
29 for (var i = 0; i < linkTags.length; ++i) {
30 linkTags[i].parentNode.removeChild(linkTags[i]);
31 }
32};
\No newline at end of file