Bug Tracker

Opened 10 years ago

Closed 8 years ago

#1555 closed bug (duplicate)

Scripts execute before being put into the document

Reported by: fstorm Owned by: john
Priority: major Milestone: 1.2
Component: ajax Version: 1.1.4
Keywords: script Cc:
Blocked by: Blocking:

Description

In jQuery 1.1.4 scripts get automatically evaluated when they're attached to the DOM. But they're also evaluated when they're attached to elements which are not part of the document DOM yet. I think scripts shouldn't be evaluated until they're attached to the document DOM.

Simple test:

function test()
{
	var test_script = "<script type=\"text/javascript\">alert(\"hello!\");</script>";

	var test_elem = jQuery("<div></div>");

	test_elem.html(test_script);
}

When executed, this function displays the alert "hello!". I think it shouldn't unless you insert test_elem into the document DOM.

This breaks compatibility between 1.1.3.1 and 1.1.4 on my website.

Change History (4)

comment:1 Changed 10 years ago by john

Owner: set to john

comment:2 Changed 9 years ago by joern

Component: coreajax

comment:3 Changed 8 years ago by dmethvin

Keywords: script added
Summary: automatic script evaluationScripts execute before being put into the document

See also #3105

comment:4 Changed 8 years ago by brandon

Resolution: duplicate
Status: newclosed

going to go ahead and close this as a duplicate of #3105 to conslidate

Note: See TracTickets for help on using tickets.