Bug Tracker

Opened 9 years ago

Closed 9 years ago

#7454 closed bug (invalid)

each() not firing under IE

Reported by: arangas Owned by:
Priority: undecided Milestone: 1.5
Component: unfiled Version: 1.4.4rc
Keywords: Cc:
Blocked by: Blocking:

Description

The following each() does not fire with jQuery 1.4.4rc2 under IE7 or IE8 (but works under Firefox 3.6, Chrome 7 and IE9):

$('Property', result).each(function () {
    var name = $('Name', this).text();
    alert("Name: " + name);
});

against sample XML:

var result = "\
<Properties>\
    <Property>\
        <Name>Title</Name>\
    </Property>\
</Properties>\
";

May also fail under previous jQuery versions (not tested).

Change History (3)

comment:1 Changed 9 years ago by arangas

comment:2 Changed 9 years ago by arangas

Please close this bug. There is a workaround for this issue in IE:

var properties = $('Property', result);
if ((properties.length == 0) && (jQuery.browser.msie)) {
	// IE screwing up
	var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
	xmlDoc.loadXML(result);
	result = xmlDoc;
	properties = $('Property', result);
}

comment:3 Changed 9 years ago by snover

Resolution: invalid
Status: newclosed

Thanks for the report, but this is not a jQuery bug. The elements you are trying to select against are not valid HTML elements, and IE causes any element that it does not recognise to be empty. This same problem happens with HTML5 elements, and is resolvable through a shim.

Note: See TracTickets for help on using tickets.