Bug Tracker

Opened 7 years ago

Closed 6 years ago

#11359 closed bug (fixed)

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

Reported by: nsfmc Owned by: Rick Waldron
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

Change History (7)

comment:1 Changed 7 years ago by Rick Waldron

#11358 is a duplicate of this ticket.

comment:2 Changed 7 years ago by Rick Waldron

Component: unfiledmanipulation
Owner: set to Rick Waldron
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

comment:3 Changed 7 years ago by Rick Waldron

Cc: dmethvin added

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.

comment:4 in reply to:  3 Changed 7 years ago by nsfmc

Replying to 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.

comment:6 Changed 7 years ago by Rick Waldron

#11493 is a duplicate of this ticket.

comment:7 Changed 6 years ago by dmethvin

Resolution: fixed
Status: assignedclosed

This should have closed when the pull was landed.

Note: See TracTickets for help on using tickets.