From b39e13b9a53e6c75f4f9364e686dc90df02b09bb Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Thu, 14 Jun 2012 16:54:54 -0700 Subject: Moving location to copy body style attribute Fixes issue with removing styles from other elements. This now only applies to HTML and Body tags --- js/document/mediators/template.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'js/document') diff --git a/js/document/mediators/template.js b/js/document/mediators/template.js index 0d48355f..e770e07f 100755 --- a/js/document/mediators/template.js +++ b/js/document/mediators/template.js @@ -145,6 +145,14 @@ exports.TemplateDocumentMediator = Montage.create(Component, { template.file.content.document.body.setAttribute(template.body.attributes[n].name, template.body.attributes[n].value); } } + // + if (template.body && template.body.getAttribute('data-ninja-style') !== null) { + template.file.content.document.body.setAttribute('style', template.body.getAttribute('data-ninja-style')); + template.file.content.document.body.removeAttribute('data-ninja-style'); + } else if (template.body && template.body.getAttribute('data-ninja-style') === null) { + template.file.content.document.body.removeAttribute('style'); + template.file.content.document.body.removeAttribute('data-ninja-style'); + } wipeAttributes(template.file.content.document.head); //Copying attributes to maintain same properties as the for (var m in template.document.head.attributes) { @@ -182,14 +190,6 @@ exports.TemplateDocumentMediator = Montage.create(Component, { //Removing attribute presentNodes[n].removeAttribute('data-ninja-node'); } - // - if (presentNodes[n].getAttribute && presentNodes[n].getAttribute('data-ninja-style') !== null) { - presentNodes[n].setAttribute('style', presentNodes[n].getAttribute('data-ninja-style')); - presentNodes[n].removeAttribute('data-ninja-style'); - } else if (presentNodes[n].getAttribute && presentNodes[n].getAttribute('data-ninja-style') === null) { - presentNodes[n].removeAttribute('style'); - presentNodes[n].removeAttribute('data-ninja-style'); - } } //Getting all CSS (style or link) tags var styletags = template.file.content.document.getElementsByTagName('style'), -- cgit v1.2.3