]> source.dussan.org Git - jquery.git/commitdiff
Attribute hooks do not need to be attached in XML docs. Fixes #9568.
authortimmywil <tim.willison@thisismedium.com>
Mon, 13 Jun 2011 14:02:13 +0000 (10:02 -0400)
committertimmywil <tim.willison@thisismedium.com>
Mon, 13 Jun 2011 14:02:13 +0000 (10:02 -0400)
src/attributes.js
test/data/dashboard.xml
test/unit/attributes.js

index 5b68773c90238764ec1550c111f41df58ed151e9..ce7b35021134a8ffa63c5c05ec9b6092678fad7b 100644 (file)
@@ -320,21 +320,23 @@ jQuery.extend({
                        notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
 
                // Normalize the name if needed
-               name = notxml && jQuery.attrFix[ name ] || name;
+               if ( notxml ) {
+                       name = jQuery.attrFix[ name ] || name;
 
-               hooks = jQuery.attrHooks[ name ];
+                       hooks = jQuery.attrHooks[ name ];
 
-               if ( !hooks ) {
-                       // Use boolHook for boolean attributes
-                       if ( rboolean.test( name ) ) {
+                       if ( !hooks ) {
+                               // Use boolHook for boolean attributes
+                               if ( rboolean.test( name ) ) {
 
-                               hooks = boolHook;
+                                       hooks = boolHook;
 
-                       // Use formHook for forms and if the name contains certain characters
-                       } else if ( formHook && name !== "className" &&
-                               (jQuery.nodeName( elem, "form" ) || rinvalidChar.test( name )) ) {
+                               // Use formHook for forms and if the name contains certain characters
+                               } else if ( formHook && name !== "className" &&
+                                       (jQuery.nodeName( elem, "form" ) || rinvalidChar.test( name )) ) {
 
-                               hooks = formHook;
+                                       hooks = formHook;
+                               }
                        }
                }
 
@@ -465,10 +467,11 @@ jQuery.extend({
                var ret, hooks,
                        notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
 
-               // Try to normalize/fix the name
-               name = notxml && jQuery.propFix[ name ] || name;
-               
-               hooks = jQuery.propHooks[ name ];
+               if ( notxml ) {
+                       // Fix name and attach hooks
+                       name = jQuery.propFix[ name ] || name;
+                       hooks = jQuery.propHooks[ name ];
+               }
 
                if ( value !== undefined ) {
                        if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) {
index 10f6b334793bb1e661dcfbac16329a1d933e9ba6..5a6f56142be9957cf19929ecb38e7a2c850e1668 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <dashboard>
        <locations class="foo">
-               <location for="bar">
+               <location for="bar" checked="different">
                        <infowindowtab>
                                <tab title="Location"><![CDATA[blabla]]></tab>
                                <tab title="Users"><![CDATA[blublu]]></tab>
index 37260f2faa48e7f0b6fd2319b363b7cb4a64c20c..831f729c34d92fd71b23272655b0a121b9161596 100644 (file)
@@ -132,11 +132,12 @@ test("attr(String)", function() {
 
 if ( !isLocal ) {
        test("attr(String) in XML Files", function() {
-               expect(2);
+               expect(3);
                stop();
                jQuery.get("data/dashboard.xml", function( xml ) {
-                       equals( jQuery( "locations", xml ).attr("class"), "foo", "Check class attribute in XML document" );
-                       equals( jQuery( "location", xml ).attr("for"), "bar", "Check for attribute in XML document" );
+                       equal( jQuery( "locations", xml ).attr("class"), "foo", "Check class attribute in XML document" );
+                       equal( jQuery( "location", xml ).attr("for"), "bar", "Check for attribute in XML document" );
+                       equal( jQuery( "location", xml ).attr("checked"), "different", "Check that hooks are not attached in XML document" );
                        start();
                });
        });