Everything I read suggests that jsdom should be executing external
scripts when configured to do so, but if I have jquery included in an
HTML template, it doesn't appear to execute it. Here's a simple
example:
jsdom.env(template, null, jsdom.defaultDocumentFeatures, function(err,
I understand that I can pass jquery in the scripts array, but I'm
hoping to let the loaded DOM dictate what scripts are available and in
what order they are loaded.
I'm guessing that I've just misinterpreted how jsdom works, but if not
I'll be happy to provide more debugging information if necessary.
On Sat, Feb 26, 2011 at 1:19 PM, Elijah Insua <tmp...@gmail.com> wrote:
>
> On Feb 26, 2011, at 12:49 PM, Branden Visser wrote:
>
> Everything I read suggests that jsdom should be executing external
> scripts when configured to do so, but if I have jquery included in an
> HTML template, it doesn't appear to execute it. Here's a simple
> example:
>
> Yeah, this is the default behavior of jsdom.jsdom() and jsdom.html().
>
>
> jsdom.env(template, null, jsdom.defaultDocumentFeatures, function(err,
>
> This is the problem! The docs state that "Since the web has some absolutely
> horrible javascript on it, as of jsdom 0.2.0 jsdom.env will not process
> external resources (scripts, images, etc)."
>
Ahh, I had mistakenly interpreted that as *default* behaviour of env,
hence why I felt it necessary to attempt to pass in the jsdom options
that specify external scripts should be executed.
> I understand that I can pass jquery in the scripts array, but I'm
> hoping to let the loaded DOM dictate what scripts are available and in
> what order they are loaded.
>
> yep, use jsdom.jsdom or jsdom.html
I understand the motive to not process external resources by default,
though I didn't have much luck using jsdom.jsdom to process external
scripts with the above example either. Was JQuery supposed to be
executed from the DOM as an external resource if I did something along
the lines of jsdom.jsdom(template)? Do you need me to rework my
example to use jsdom.jsdom for you to see what I'm doing wrong?
Thanks,
Branden
Hi elijah, I was digging through the tests and found that I need to use the onload event to grab the resulting template (duh!).
Thanks again for your help!
Branden
On 2011-02-26 1:30 PM, "Branden Visser" <mrvi...@gmail.com> wrote:
Thanks for your quick reply Elijah. If you don't mind, I have some
follow-up questions below:
On Sat, Feb 26, 2011 at 1:19 PM, Elijah Insua <tmp...@gmail.com> wrote:
>
> On Feb 26, 2011, at 12:...
Ahh, I had mistakenly interpreted that as *default* behaviour of env,
hence why I felt it necessary to attempt to pass in the jsdom options
that specify external scripts should be executed.
> I understand that I can pass jquery in the scripts array, but I'm
> hoping to let the loaded DOM ...