-
Notifications
You must be signed in to change notification settings - Fork 14
/
css.js
32 lines (29 loc) · 1.13 KB
/
css.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
define({
load: function (name, req, load, config, map) {
var url = name,
path = url.split('/'),
linkElement = document.createElement('link'),
headElement = document.getElementsByTagName('head')[0],
parentModuleName = map && map.parentMap && map.parentMap.name,
parentScriptElement,
i,
childNode;
linkElement.setAttribute('href', url);
linkElement.setAttribute('rel', 'stylesheet');
if (parentModuleName) {
for (i = 0 ; i < headElement.childNodes.length ; i += 1) {
childNode = headElement.childNodes[i];
if (childNode.nodeType === 1 && childNode.nodeName.toLowerCase() === 'script' && childNode.getAttribute('data-requiremodule') === parentModuleName) {
parentScriptElement = childNode;
break;
}
}
}
if (parentScriptElement) {
headElement.insertBefore(linkElement, parentScriptElement);
} else {
headElement.appendChild(linkElement);
}
load();
}
});