From 92405d4f5ffe9ec1f26f280303783014948438c5 Mon Sep 17 00:00:00 2001 From: timmywil Date: Mon, 12 Sep 2011 19:40:14 -0400 Subject: Override Sizzle attribute retrieval with jQuery.attr. Fixes #5637, #7128, #9261, #9570, #10178. Bug fixed on the side: $(window).is('a') was throwing an exception. Fixes #10178. --- src/attributes.js | 12 ++++++++---- src/sizzle | 2 +- src/sizzle-jquery.js | 3 +++ 3 files changed, 12 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/attributes.js b/src/attributes.js index dd985b494..6380b7d6c 100644 --- a/src/attributes.js +++ b/src/attributes.js @@ -7,7 +7,7 @@ var rclass = /[\n\t\r]/g, rfocusable = /^(?:button|input|object|select|textarea)$/i, rclickable = /^a(?:rea)?$/i, rboolean = /^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i, - nodeHook, boolHook; + nodeHook, boolHook, fixSpecified; jQuery.fn.extend({ attr: function( name, value ) { @@ -519,15 +519,19 @@ boolHook = { // IE6/7 do not support getting/setting some attributes with get/setAttribute if ( !jQuery.support.getSetAttribute ) { - + + fixSpecified = { + name: true, + id: true + }; + // Use this for any attribute in IE6/7 // This fixes almost every IE6/7 issue nodeHook = jQuery.valHooks.button = { get: function( elem, name ) { var ret; ret = elem.getAttributeNode( name ); - // Return undefined if nodeValue is empty string - return ret && ret.nodeValue !== "" ? + return ret && (fixSpecified[ name ] ? ret.nodeValue !== "" : ret.specified) ? ret.nodeValue : undefined; }, diff --git a/src/sizzle b/src/sizzle index 93cc46709..3375f91f7 160000 --- a/src/sizzle +++ b/src/sizzle @@ -1 +1 @@ -Subproject commit 93cc46709e03173288111f8b60d4192fea2ec8d0 +Subproject commit 3375f91f7c0503da1cd34ae9b6bbbd7be07bf64d diff --git a/src/sizzle-jquery.js b/src/sizzle-jquery.js index f15b08252..7090e1c63 100644 --- a/src/sizzle-jquery.js +++ b/src/sizzle-jquery.js @@ -1,3 +1,6 @@ +// Override sizzle attribute retrieval +Sizzle.attr = jQuery.attr; +Sizzle.selectors.attrMap = {}; jQuery.find = Sizzle; jQuery.expr = Sizzle.selectors; jQuery.expr[":"] = jQuery.expr.filters; -- cgit v1.2.3