diff --git a/tApp.js b/tApp.js index ec2cd13..9f58381 100644 --- a/tApp.js +++ b/tApp.js @@ -7,7 +7,7 @@ class tApp { static database; static currentHash = "/"; static get version() { - return "v0.6.0"; + return "v0.6.1"; } static configure(params) { if(params == null) { @@ -303,6 +303,32 @@ class tApp { throw "tAppError: No target DOM specified, use tApp.config.target to set the target." } tApp.config.target.innerHTML = html; + function nodeScriptReplace(node) { + if (nodeScriptIs(node) === true) { + node.parentNode.replaceChild(nodeScriptClone(node), node); + } else { + var i = -1, children = node.childNodes; + while (++i < children.length) { + nodeScriptReplace(children[i]); + } + } + return node; + } + function nodeScriptClone(node){ + var script = document.createElement("script"); + script.text = node.innerHTML; + + var i = -1, attrs = node.attributes, attr; + while (++i < attrs.length) { + script.setAttribute((attr = attrs[i]).name, attr.value); + } + return script; + } + + function nodeScriptIs(node) { + return node.tagName === 'SCRIPT'; + } + nodeScriptReplace(tApp.config.target); } static renderFile(path) { tApp.get(path).then((res) => {