Bug Tracker

Modify

Ticket #6212 (closed bug: patchwelcome)

Opened 4 years ago

Last modified 3 years ago

IE6 loads images twice when adding HTML snuippet with $.html() or $.load()

Reported by: sanelson Owned by:
Priority: undecided Milestone:
Component: manipulation Version: 1.4.2
Keywords: Cc:
Blocking: Blocked by:

Description

I have an Ajax call that returns an HTML snippet containing <img> tags, among other things. The src of one of these images is actually a Java servlet, which returns an image when called. On IE6, this servlet gets called twice.

On line 4191 in jquery.js, it is doing a check to see if this snippet can be inserted with innerHTML. This check fails in IE6, but passes in Firefox and seems to pass in IE7+ (I'm having trouble debugging IE7+, so I can't say for sure, but the issue doesn't exist in IE8 running in compatibility mode). On IE6, jQuery goes on to use append() to add the HTML snippet, which calls clean().

In the clean method, on line 4447, it calls:

div.innerHTML = wrap[1] + elem + wrap[2];

This causes IE to load all the images, and call the servlet.

Then, on line 4477, it does this:

div.insertBefore( context.createTextNode( rleadingWhitespace.exec(elem)[0] ), div.firstChild );

This again, causes IE to load all the images, and it calls the servlet again.

It seems the there are two issues here: 1) This should simply be getting loaded with innerHTML on IE6 just like every other browser. 2) When using append(), the images should not be loaded twice.

Attachments

ajax-calls.js Download (636 bytes) - added by sanelson 4 years ago.
Ajax calls
ajax-response.html Download (5.6 KB) - added by sanelson 4 years ago.
Ajax response

Change History

Changed 4 years ago by sanelson

Ajax calls

Changed 4 years ago by sanelson

Ajax response

comment:1 Changed 4 years ago by dmethvin

  • Component changed from unfiled to manipulation

comment:2 Changed 3 years ago by snover

  • Milestone 1.4.3 deleted

Resetting milestone to future.

comment:3 Changed 3 years ago by snover

  • Priority set to undecided
  • Status changed from new to closed
  • Resolution set to patchwelcome

Most things do not fall over when hit twice, and there are other corner-cases in IE6 that will cause duplicate loading of external resources as well that can’t be resolved. That said, please feel free to submit a patch that corrects this issue if you’ve got one, and we will consider it for inclusion.

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.