Load tree virtual scripts sequentially

urbit/tree@4eeaad4
This commit is contained in:
Anton Dyudin 2016-03-04 16:04:07 -08:00
parent f51226fd6e
commit 4f58c390d5

View File

@ -1356,12 +1356,25 @@ module.exports = _.extend(reactify, {
},{"../stores/TreeStore.coffee":22,"./LoadComponent.coffee":12}],15:[function(require,module,exports){
var recl, rele;
var appendNext, recl, rele, waitingScripts;
recl = React.createClass;
rele = React.createElement;
waitingScripts = null;
appendNext = function() {
if (waitingScripts == null) {
return;
}
if (waitingScripts.length === 0) {
return waitingScripts = null;
} else {
return document.body.appendChild(waitingScripts.shift());
}
};
module.exports = recl({
displayName: "Script",
componentDidMount: function() {
@ -1369,8 +1382,14 @@ module.exports = recl({
s = document.createElement('script');
_.assign(s, this.props);
urb.waspElem(s);
document.body.appendChild(s);
return this.js = s;
s.onload = appendNext;
this.js = s;
if (waitingScripts != null) {
return waitingScripts.push(s);
} else {
waitingScripts = [s];
return appendNext();
}
},
componentWillUnmount: function() {
return document.body.removeChild(this.js);