From 13ae16997d4bbca14e255d5989d1c44a76eac72c Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Wed, 16 May 2012 15:23:48 -0700 Subject: montage v.0.10 integration Signed-off-by: Valerio Virgillito --- node_modules/montage/ui/loader.reel/loader.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'node_modules/montage/ui/loader.reel/loader.js') diff --git a/node_modules/montage/ui/loader.reel/loader.js b/node_modules/montage/ui/loader.reel/loader.js index 921c3781..2ff0e42c 100755 --- a/node_modules/montage/ui/loader.reel/loader.js +++ b/node_modules/montage/ui/loader.reel/loader.js @@ -222,7 +222,9 @@ exports.Loader = Montage.create(Component, /** @lends module:montage/ui/loader.L logger.debug(this, "templateDidLoad"); } - this.element = document.documentElement; + if (!this.element) { + this.element = document.documentElement; + } this.readyToShowLoader = true; var timing = document._montageTiming, @@ -348,7 +350,8 @@ exports.Loader = Montage.create(Component, /** @lends module:montage/ui/loader.L childComponentWillPrepareForDraw: { value: function(child) { - var self = this; + var self = this, + insertionElement; // if the mainComponent is ready to draw... if (child === this._mainComponent) { @@ -360,11 +363,15 @@ exports.Loader = Montage.create(Component, /** @lends module:montage/ui/loader.L // Determine old content this._contentToRemove = document.createRange(); - this._contentToRemove.selectNodeContents(document.body); + + // If installing classnames on the documentElement (to affect as high a level as possible) + // make sure content only ends up inside the body + insertionElement = this.element === document.documentElement ? document.body : this.element; + this._contentToRemove.selectNodeContents(insertionElement); // Add new content so mainComponent can actually draw this.childComponents = [this._mainComponent]; - document.body.appendChild(this._mainComponent.element); + insertionElement.appendChild(this._mainComponent.element); var startBootstrappingTimeout = document[bootstrappingTimeoutPropertyName], timing = document._montageTiming, -- cgit v1.2.3