Execute scripts appended to DOM by code
Reported by Wes Biggs | January 2nd, 2009 @ 02:59 PM | in 1.0 Release
In addition to executing scripts on document load, we need to execute scripts that are dynamically generated in the document.
I added the following in appendChild:
appendChild: function(node){
this._dom.appendChild( node._dom );
// BEGIN PATCH
if (node.tagName == 'SCRIPT') {
if (node.getAttribute("src")) {
setTimeout(function() { load(node.src); },0);
} else {
setTimeout(node.textContent,0);
}
}
// END PATCH
},
This is a little too naive, though; we'd like the src attribute to load relative to window.location. This is more properly handled by the generic script executor (we may need to write some code to parse relative URLs).
Comments and changes to this ticket
-
thatcher.christopher (at gmail) January 19th, 2009 @ 09:16 PM
- State changed from new to open
- Assigned user set to thatcher.christopher (at gmail)
ok I added a new policy file that by default allows the scripts to be executed based on a policy.
By default this is set to
$policy.loadScripts = $env.safeScript;
which will not execute any scripts other than those loaded through rhino.
you can change this to
$policy.loadScripts = $env.loadLocalScripts;
This will load the scripts defined relative to the window.location or inline scripts.
I didnt address loading of remote scripts yet but will do.
This is in http://github.com/thatcher/env-js
going to leave this open until remote scripts are addressed.
-
thatcher.christopher (at gmail) January 31st, 2009 @ 06:20 AM
- Milestone set to 1.0 Release
-
Thatcher February 1st, 2009 @ 04:27 PM
- Tag set to client, loading, script, server, strategy, textenvjs, textjavascript
- Assigned user changed from thatcher.christopher (at gmail) to Thatcher
Still leaving this as open as we push to a 0.1 release.
However I just committed what I think is the best script loading implementation yet. I took the advice from the original ticket post and load if the script ownerDocument is the window document. its loaded relative to window loacation . And as a precaution the scripts is currently only loaded in the type contains text/envjs but also supports ;-delimited types so you can have text/javascript;text/envjs.
-
Thatcher February 17th, 2009 @ 04:37 AM
- State changed from open to resolved
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป
a javascript browser environment