Skip to content

Instantly share code, notes, and snippets.

@sdesai
Created September 12, 2011 19:52
Show Gist options
  • Save sdesai/1212204 to your computer and use it in GitHub Desktop.
Save sdesai/1212204 to your computer and use it in GitHub Desktop.
_uiAddChild: function (child, parentNode) {
// Out of the box, this is never async, so things will always work, even if children are
// rendered out of order.
// The plugin modifies this code to be async (by moving the defRenderFn to an async queue).
// Since it's doing this, I think it's also appropriate for it to override any methods
// which were written based on the assumption that child.render() was always synchronous.
child.render(parentNode);
// If render() is made async, we can't rely on this being invoked with content in the DOM, so
var childBB = child.get("boundingBox"),
siblingBB,
nextSibling = child.next(false),
prevSibling;
if (nextSibling) {
siblingBB = nextSibling.get(BOUNDING_BOX);
siblingBB.insert(childBB, "before");
} else {
prevSibling = child.previous(false);
if (prevSibling) {
siblingBB = prevSibling.get(BOUNDING_BOX);
siblingBB.insert(childBB, "after");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment