Skip to main content

Bug Tracker

Side navigation

#10903 closed bug (patchwelcome)

Opened November 27, 2011 03:57PM UTC

Closed June 04, 2012 05:45PM UTC

'append' in IE local intranet web site does not work well with if Internet security zone Active Scripting is disabled

Reported by: ewolfman@yahoo.com Owned by:
Priority: low Milestone: 1.8
Component: manipulation Version: 1.7.1
Keywords: Cc: dmethvin
Blocked by: Blocking:
Description

Although this is probably an IE only bug, jQuery "falls" for it and a workaround can be easily provided. Steps to reproduce:

1. Insert an new element using 'append' with an 'onclick' event.

2. In IE, set Local Intranet security zone's Active Scripting to Enabled, and Internet security zone's Active Scripting to disabled.

3. Ensure that the html is running on a local web site, by right clicking and selecting Properties on the browsed page. It should read as "Local Intranet" (otherwise the bug will not reproduce).

4. Browse the page. The 'onclick' is not triggered.

This seems like an IE bug. It seems like setting the innerHTML property on a new element not yet in the DOM causes IE to ignore the event. If innerHTML is performed on an element that exists in the DOM, the event is triggered correctly. For example: jQuery's 'html' works well because it replaces the innerHTML for an element already in the DOM.

The requested bug fix/workaround is that 'append' (and possibly other jQuery DOM insertion methods) will change the order of things: set the innerHTML after appending the element to the DOM, and not prior to it.

Attachments (0)
Change History (5)

Changed November 27, 2011 04:29PM UTC by rwaldron comment:1

cc: → dmethvin
component: unfiledmanipulation
priority: undecidedlow

It's unreasonable to dictate the order of execution as you've requested, especially when significant performance gains can be achieved by setting HTML in detached nodes, prior to insertion.

This seems like an edge case, I'd like Dave Methvin to weigh in on this (his IE experience is second to none)

Changed November 28, 2011 12:21AM UTC by dmethvin comment:2

blockedby: → 10515
milestone: None1.8

None of the HTML processing code in jQuery.clean or jQuery.buildFragment currently attaches content to the document, that's done later when the method-specific callback (e.g., append, prepend, before, after) is called. So this isn't a simple change and a very cornery case.

However, we've been talking about using insertAdjacentHTML in #10515 which might solve this problem so I'll leave it open. If it can't be worked in there I think we will close this wontfix.

Changed November 28, 2011 12:21AM UTC by dmethvin comment:3

status: newopen

Changed June 04, 2012 05:44PM UTC by dmethvin comment:4

blockedby: 10515

Changed June 04, 2012 05:45PM UTC by dmethvin comment:5

resolution: → patchwelcome
status: openclosed

This doesn't have a simple and performant resolution. If you need to do this, request the content as text and inject it into your own <div> in the document so that IE will think it belongs there, then use jQuery methods to move it elsewhere. Doing this will cause reflows so try to avoid it at all costs.