Bug Tracker

Modify

Ticket #11359 (closed bug: fixed)

Opened 15 months ago

Last modified 11 months ago

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

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

comment:1 Changed 15 months ago by rwaldron

#11358 is a duplicate of this ticket.

comment:2 Changed 15 months ago by rwaldron

  • Owner set to rwaldron
  • Priority changed from undecided to high
  • Status changed from new to assigned
  • Component changed from unfiled to manipulation

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 follow-up: ↓ 4 Changed 15 months ago by rwaldron

  • 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 15 months 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 14 months ago by rwaldron

#11493 is a duplicate of this ticket.

comment:7 Changed 11 months ago by dmethvin

  • Status changed from assigned to closed
  • Resolution set to fixed

This should have closed when the pull was landed.

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.