Skip to content

Commit

Permalink
Followup b576034: restore oldIE support
Browse files Browse the repository at this point in the history
  • Loading branch information
gibson042 committed Feb 18, 2013
1 parent d1d0cf8 commit 1ef7c09
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions sizzle.js
Original file line number Diff line number Diff line change
Expand Up @@ -371,25 +371,24 @@ setDocument = Sizzle.setDocument = function( node ) {
return div.getElementsByClassName("e").length === 2;
});

// Check if getElementById returns elements by name
// Check if getElementsByName privileges form controls or returns elements by ID
// If so, assume (for broader support) that getElementById returns elements by name
support.getByName = assert(function( div ) {
// Inject content
div.id = expando + 0;
// Support: Windows 8 Native Apps
// Assigning innerHTML with "name" attributes throws uncatchable exceptions
// http://msdn.microsoft.com/en-us/library/ie/hh465388.aspx
div.appendChild( document.createElement("a") ).setAttribute( "name", expando );
div.appendChild( document.createElement("div") ).setAttribute( "name", expando );
docElem.insertBefore( div, docElem.firstChild );
div.appendChild( document.createElement("i") ).setAttribute( "name", expando );
docElem.appendChild( div );

// Test
var pass = doc.getElementsByName &&
// buggy browsers will return fewer than the correct 2
doc.getElementsByName( expando ).length === 2 +
// buggy browsers will return more than the correct 0
doc.getElementsByName( expando + 0 ).length;
support.getIdNotName = !doc.getElementById( expando );

// Cleanup
docElem.removeChild( div );
Expand Down Expand Up @@ -424,7 +423,7 @@ setDocument = Sizzle.setDocument = function( node ) {
};

// ID find and filter
if ( support.getIdNotName ) {
if ( support.getByName ) {
Expr.find["ID"] = function( id, context ) {
if ( typeof context.getElementById !== strundefined && !documentIsXML ) {
var m = context.getElementById( id );
Expand Down

0 comments on commit 1ef7c09

Please sign in to comment.