#32 ✓resolved

Inline scripts are not executed

Reported by fiann | February 10th, 2009 @ 01:38 AM | in 1.0 Release

Scripts that are declared inline in the html page are not executed correctly. This is because the html parser is showing the script body as empty.

To replicate this load any html page with an inline

print("loading inline script :" + script.text);

script.text is empty because the HTML parser appends the text content as a child node of type TEXT_NODE. So we can get the correct content with:

print("loading inline script :" + script.childNodes[0].nodeValue);

Comments and changes to this ticket

  • fiann

    fiann February 10th, 2009 @ 01:43 AM

    This patch changes the html parser to return the contents of the child text node from the text() function, rather than contents of the node itself.

    Incidentally, this issue also seems to affect the HTMLOptionElement node type, but I don't have a test case for that.

  • fiann

    fiann February 10th, 2009 @ 03:40 AM

    A second problem is that if the JS contains a less than operator < or any ampersands, then it has to be in a CDATA block so pass through the XML parser correctly.

    This patch looks for the source in a CDATA block if any, then in the text node. The first text node can be discarded if there is a CDATA block because it will typically be a JS comment so that older browsers ignore the CDATA declaration.

  • Thatcher

    Thatcher February 16th, 2009 @ 08:25 AM

    • Milestone set to 1.0 Release
    • Tag set to cdata, childnodes, inline, nodevalue, script, text
    • State changed from “new” to “open”
    • Assigned user set to “Thatcher”

    Nice catch Fiann, I added your patch and will close this ticket when I commit and push.


  • Thatcher

    Thatcher February 17th, 2009 @ 04:39 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.

New-ticket Create new ticket

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

People watching this ticket


Referenced by