-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.js
30 lines (30 loc) · 962 Bytes
/
init.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
define(function(require, exports, module) {
var head = document.head || document.getElementsByTagName('head')[0];
var migi = require('./web/migi')['default'];
migi.init = function() {
var jsx = document.querySelectorAll('script');
for(var i = 0, len = jsx.length; i < len; i++) {
var node = jsx[i];
if(node.getAttribute('type') == 'text/jsx') {
var code = node.text;
// node.parentNode.removeChild(node);
if(!code) {
continue;
}
var charset = node.getAttribute('charset');
var crossorigin = node.getAttribute('crossorigin');
var script = document.createElement('script');
if(charset) {
script.charset = charset;
}
if(crossorigin) {
node.setAttribute('crossorigin', crossorigin);
}
script.async = true;
script.text = code;
head.appendChild(script);
}
}
}
module.exports = migi;
});