Adopt latest loader

上级 c36a8573
......@@ -51,13 +51,7 @@ var CSSLoaderPlugin;
BrowserCSSLoader.prototype._insertLinkNode = function (linkNode) {
this._pendingLoads++;
var head = document.head || document.getElementsByTagName('head')[0];
var other = head.getElementsByTagName('link') || head.getElementsByTagName('script');
if (other.length > 0) {
head.insertBefore(linkNode, other[other.length - 1]);
}
else {
head.appendChild(linkNode);
}
head.appendChild(linkNode);
};
BrowserCSSLoader.prototype.createLinkTag = function (name, cssUrl, externalCallback, externalErrorback) {
var _this = this;
......
......@@ -681,13 +681,33 @@ var AMDLoader;
};
return BrowserScriptLoader;
}());
function canUseEval(moduleManager) {
var trustedTypesPolicy = moduleManager.getConfig().getOptionsLiteral().trustedTypesPolicy;
try {
var func = (trustedTypesPolicy
? self.eval(trustedTypesPolicy.createScript('', 'true'))
: new Function('true'));
func.call(self);
return true;
}
catch (err) {
return false;
}
}
var WorkerScriptLoader = /** @class */ (function () {
function WorkerScriptLoader() {
this._cachedCanUseEval = null;
}
WorkerScriptLoader.prototype._canUseEval = function (moduleManager) {
if (this._cachedCanUseEval === null) {
this._cachedCanUseEval = canUseEval(moduleManager);
}
return this._cachedCanUseEval;
};
WorkerScriptLoader.prototype.load = function (moduleManager, scriptSrc, callback, errorback) {
var trustedTypesPolicy = moduleManager.getConfig().getOptionsLiteral().trustedTypesPolicy;
var isCrossOrigin = (/^((http:)|(https:)|(file:))/.test(scriptSrc) && scriptSrc.substring(0, self.origin.length) !== self.origin);
if (!isCrossOrigin) {
if (!isCrossOrigin && this._canUseEval(moduleManager)) {
// use `fetch` if possible because `importScripts`
// is synchronous and can lead to deadlocks on Safari
fetch(scriptSrc).then(function (response) {
......
......@@ -33,7 +33,7 @@ var NLSLoaderPlugin;
this._detect();
return this._isPseudo;
},
enumerable: true,
enumerable: false,
configurable: true
});
Environment.prototype._detect = function () {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册