ajaxorg/apf — pull request #58 by javruben (2012-04-02 23:28:25+00:00)
Title: Hotfix/domparser conflict

@janjongboom @mostafaeweda

This is the fix for the problem you wrote me about:

'insertMarkup' can't be executed in parallel, but it doesn't implement any queue'ing mechanism or something. (Or it could even mean that it breaks after the first insertMarkup call, don't know this for sure). Therefore we run into timing issues on the deploy plugins, who all use insertMarkup to inject themselves into the deploy 'holder' element.

The reason it exits is this I believe:

var doc = this.nodeType == this.NODE_DOCUMENT ? this : this.ownerDocument;
if (!doc || doc.$domParser.$shouldWait) {
return amlNode;
}

doc.$domParser.$shouldWait is '1' here. At the moment this means that (on c9.io) Azure won't load every once in a while, and on the cloudfoundry branch only 1 deploy target loads (most of the time, and the one that loads is random, because timing issue).

It's pretty easy to test by calling this multiple times:

var options = {
callback: function(inserted) {
var childNodes = inserted.amlNode.childNodes;
childNodes.shift();
var insertedXmlNodes = childNodes.map(function(n) {
return n.$aml;
});
this.nodes = this.nodes.concat(insertedXmlNodes);
this.signinChecking();

this.setupModelEvents();
herokuSignin.setProperty("visible", true);
}.bind(this)
};
var res = hboxHeroku.insertMarkup(markup, options);

The callback doesn't always get fired.