Skip to main content

Bug Tracker

Side navigation

#11359 closed bug (fixed)

Opened February 17, 2012 12:32AM UTC

Closed June 26, 2012 02:40AM UTC

.clone() deletes / empties contents of inline SCRIPT tags

Reported by: nsfmc Owned by: rwaldron
Priority: high Milestone: None
Component: manipulation Version: 1.7.1
Keywords: Cc: dmethvin
Blocked by: Blocking:
Description

test case: http://jsfiddle.net/QCp2P/3/

until the .clone() is called, it's possible to query the contents of the script with .html()

The behavior works correctly in ff/safari/chrome, but in IE it seems that the cloning is causing the node to be emptied out even though the script is of type='foo/bar'

i'm not sure if this is related to this:

https://github.com/jquery/jquery/blob/master/src/manipulation.js#L592

Attachments (0)
Change History (7)

Changed February 17, 2012 02:56AM UTC by rwaldron comment:1

#11358 is a duplicate of this ticket.

Changed February 17, 2012 03:01AM UTC by rwaldron comment:2

component: unfiledmanipulation
owner: → rwaldron
priority: undecidedhigh
status: newassigned

This is caused by our use of innerHTML as a better way to clone nodes in older IEs.

I'll patch this tonight

Changed February 17, 2012 03:42PM UTC by rwaldron comment:3

cc: → dmethvin

So, I took a closer look at this and realized that the problem you're having is caused by jQuery only looking for scripts that might be able to execute code when it does any kind of html manipulation with html(), clone() etc.

I can't see a simple or straightforward solution.

Changed February 17, 2012 06:22PM UTC by nsfmc comment:4

Replying to [comment:3 rwaldron]:

So, I took a closer look at this and realized that the problem you're having is caused by jQuery only looking for scripts that might be able to execute code when it does any kind of html manipulation with html(), clone() etc. I can't see a simple or straightforward solution.

although in my situation, i'm certainly executing the contents of the script tag, this seems like it would be potentially problematic if you were potentially cloning a script tag with type="text/handlebars".

again, i can agree that the use case for that is ''probably weak'', but i'm trying to avoid putting code in divs (which we already do right now, potentially for this very reason).

thanks again for any insight.

Changed February 17, 2012 07:22PM UTC by gibson042 comment:5

Changed March 20, 2012 07:38PM UTC by rwaldron comment:6

#11493 is a duplicate of this ticket.

Changed June 26, 2012 02:40AM UTC by dmethvin comment:7

resolution: → fixed
status: assignedclosed

This should have closed when the pull was landed.