-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathextjsx.js
78 lines (67 loc) · 2.11 KB
/
extjsx.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
(function(){
var orgGetPath = Ext.Loader.getPath,
orgloadScriptFile = Ext.Loader.loadScriptFile,
transformer = JSXTransformer;
// modified load method from JSXTransformer
function load (url, options) {
var xhr;
xhr = window.ActiveXObject ? new window.ActiveXObject('Microsoft.XMLHTTP')
: new XMLHttpRequest();
// Disable async since we need to execute scripts in the order they are in the
// DOM to mirror normal script loading.
xhr.open('GET', url, false);
if ('overrideMimeType' in xhr) {
xhr.overrideMimeType('text/plain');
}
xhr.onreadystatechange = function() {
if (xhr.readyState === 4) {
if (xhr.status === 0 || xhr.status === 200) {
var responseText = xhr.responseText;
if(options && options.beforeRun){
responseText = options.beforeRun(responseText);
}
transformer.run(responseText);
} else {
throw new Error("Could not load " + url);
}
if (options && options.callback) {
return options.callback(responseText);
}
}
};
return xhr.send(null);
}
function beforeLoadFn (responseText) {
return "/** @jsx React.DOM */" + responseText;
}
Ext.Loader.getPath = function (className) {
this.LAST_CLASS_NAME = className;
return orgGetPath.call(this, className);
};
Ext.Loader.loadScriptFile = function (url, onLoad, onError, scope, synchronous) {
if (scope.isFileLoaded[url]) {
return Ext.Loader;
}
var config = Ext.Loader.getConfig(),
noCacheUrl = url + (config.disableCaching ? ('?' + config.disableCachingParam + '=' + Ext.Date.now()) : ''),
isCrossOriginRestricted = false,
xhr, status, onScriptError,
debugSourceURL = "";
scope = scope || Ext.Loader;
Ext.Loader.isLoading = true;
if(scope.LAST_CLASS_NAME.indexOf('react') !== -1){
try {
load(noCacheUrl, {
beforeRun: beforeLoadFn,
callback: function () { onLoad.call(scope); }
});
}
catch(e){
onError.call(scope);
}
}
else {
orgloadScriptFile.call(this, url, onLoad, onError, scope, synchronous);
}
};
})()