Bug Tracker

Ticket #1555 (closed bug: duplicate)

Opened 8 years ago

Last modified 6 years ago

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:
Blocking: Blocked by:


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>");


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 and 1.1.4 on my website.

Change History

comment:1 Changed 8 years ago by john

  • Owner set to john

comment:2 Changed 8 years ago by joern

  • Component changed from core to ajax

comment:3 Changed 7 years ago by dmethvin

  • Keywords script added
  • Summary changed from automatic script evaluation to Scripts execute before being put into the document

See also #3105

comment:4 Changed 6 years ago by brandon

  • Status changed from new to closed
  • Resolution set to duplicate

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

Note: See TracTickets for help on using tickets.