Side navigation
#6516 closed bug (fixed)
Opened May 03, 2010 03:08AM UTC
Closed April 17, 2011 05:15PM UTC
Last modified February 25, 2013 04:34AM UTC
replaceWith using DOM element with nested script does not run script
Reported by: | Phrogz | Owned by: | |
---|---|---|---|
Priority: | low | Milestone: | 1.5 |
Component: | manipulation | Version: | 1.4.4 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
var div = $('<div><script type="text/javascript">alert("hi")<\\/script><\\/div>');
$('#foo').replaceWith( div[0] );
In jQuery 1.3.2, the above runs the code in the script block. In jQuery 1.4.2, the code is not run.
If you remove the [0], both 1.3 and 1.4 work. You can see test cases at http://phrogz.net/tmp/jquery_js_in_html/
Attachments (2)
Change History (6)
Changed June 12, 2010 02:09AM UTC by comment:1
component: | unfiled → core |
---|
Changed November 12, 2010 02:40AM UTC by comment:2
milestone: | 1.4.3 |
---|
Resetting milestone to future.
Changed November 21, 2010 02:47AM UTC by comment:3
priority: | → undecided |
---|
I can confirm that this issue is present with jQuery 1.4.2, 1.4.3 and 1.4.4, however as mentioned removing [0] does allow the original desired behavior to work Live Test Case.
Changed November 21, 2010 04:15AM UTC by comment:4
status: | new → open |
---|---|
version: | 1.4.2 → 1.4.4 |
Changed April 17, 2011 05:15PM UTC by comment:5
component: | core → manipulation |
---|---|
milestone: | → 1.5 |
priority: | undecided → low |
resolution: | → fixed |
status: | open → closed |
It seems this bug is no longer present according to the test case provided by addy.
Changed February 25, 2013 04:34AM UTC by comment:6
I see this issue with jquery1.7.2 - has this issue been fixed? I was seeing this issue in my script and moodified the above test script to use jquery1.7.2.js and replaceWith is not running script.