From d4e4414451e15d23d7174e8eeddaa952ed0e4d73 Mon Sep 17 00:00:00 2001 From: jeresig Date: Sun, 6 Mar 2011 22:47:40 -0500 Subject: [PATCH 01/42] Very crude first pass at splitting apart the attr/prop logic. Also adding in attrHooks/propHooks. All of it is completely untested. --- src/attributes.js | 274 ++++++++++++++++++++++++++++------------------ 1 file changed, 168 insertions(+), 106 deletions(-) diff --git a/src/attributes.js b/src/attributes.js index 59972105..e5425a05 100644 --- a/src/attributes.js +++ b/src/attributes.js @@ -3,38 +3,37 @@ var rclass = /[\n\t\r]/g, rspaces = /\s+/, rreturn = /\r/g, - rspecialurl = /^(?:href|src|style)$/, rtype = /^(?:button|input)$/i, rfocusable = /^(?:button|input|object|select|textarea)$/i, rclickable = /^a(?:rea)?$/i, rradiocheck = /^(?:radio|checkbox)$/i; -jQuery.props = { - "for": "htmlFor", - "class": "className", - readonly: "readOnly", - maxlength: "maxLength", - cellspacing: "cellSpacing", - rowspan: "rowSpan", - colspan: "colSpan", - tabindex: "tabIndex", - usemap: "useMap", - frameborder: "frameBorder" -}; - jQuery.fn.extend({ attr: function( name, value ) { return jQuery.access( this, name, value, true, jQuery.attr ); }, - removeAttr: function( name, fn ) { - return this.each(function(){ - jQuery.attr( this, name, "" ); + removeAttr: function( name ) { + return this.each(function() { if ( this.nodeType === 1 ) { this.removeAttribute( name ); } }); }, + + prop: function( name, value ) { + return jQuery.access( this, name, value, true, jQuery.prop ); + }, + + removeProp: function( name ) { + return this.each(function() { + // try/catch handles cases where IE balks (such as removing a property on window) + try { + this[ name ] = undefined; + delete this[ name ]; + } catch( e ) {} + }); + }, addClass: function( value ) { if ( jQuery.isFunction(value) ) { @@ -275,6 +274,21 @@ jQuery.extend({ height: true, offset: true }, + + // TODO: Check to see if any of these are needed anymore? + // If not, it may be good to standardize on all-lowercase names instead + attrFix: { + "for": "htmlFor", + "class": "className", + readonly: "readOnly", + maxlength: "maxLength", + cellspacing: "cellSpacing", + rowspan: "rowSpan", + colspan: "colSpan", + tabindex: "tabIndex", + usemap: "useMap", + frameborder: "frameBorder" + }, attr: function( elem, name, value, pass ) { // don't get/set attributes on text, comment and attribute nodes @@ -286,104 +300,152 @@ jQuery.extend({ return jQuery(elem)[name](value); } - var notxml = elem.nodeType !== 1 || !jQuery.isXMLDoc( elem ), - // Whether we are setting (or getting) - set = value !== undefined; - + var ret, + notxml = elem.nodeType !== 1 || !jQuery.isXMLDoc( elem ), + hooks; + // Try to normalize/fix the name - name = notxml && jQuery.props[ name ] || name; + name = notxml && jQuery.attrFix[ name ] || name; + + hooks = jQuery.attrHooks[ name ]; + + if ( value !== undefined ) { + + if ( hooks && "set" in hooks && notxml && (ret = hooks.set( elem, value )) !== undefined ) { + return ret; + + } else { + // convert the value to a string (all browsers do this but IE) see #1070 + value = "" + value; + + elem.setAttribute( name, value ); + + return value; + } + + } else { + + if ( hooks && "get" in hooks && notxml && (ret = hooks.get( elem )) !== undefined ) { + return ret; + + } else { + + if ( !jQuery.hasAttr( elem, name ) ) { + return undefined; + } - // Only do all the following if this is a node (faster for style) - if ( elem.nodeType === 1 ) { - // These attributes require special treatment - var special = rspecialurl.test( name ); + var attr = elem.getAttribute( name ); - // Safari mis-reports the default selected property of an option - // Accessing the parent's selectedIndex property fixes it - if ( name === "selected" && !jQuery.support.optSelected ) { - var parent = elem.parentNode; - if ( parent ) { - parent.selectedIndex; - - // Make sure that it also works with optgroups, see #5701 - if ( parent.parentNode ) { - parent.parentNode.selectedIndex; - } + // Non-existent attributes return null, we normalize to undefined + return attr === null ? + undefined : + attr; + } + } + }, + + hasAttr: function( elem, name ) { + // Blackberry 4.7 returns "" from getAttribute #6938 + return elem.attributes[ name ] || (elem.hasAttribute && elem.hasAttribute( name )); + }, + + attrHooks: { + type: { + set: function( elem, value ) { + // We can't allow the type property to be changed (since it causes problems in IE) + if ( rtype.test( elem.nodeName ) && elem.parentNode ) { + jQuery.error( "type property can't be changed" ); } } + }, + + // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set + // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/ + tabIndex: { + get: function( elem ) { + var attributeNode = elem.getAttributeNode( "tabIndex" ); - // If applicable, access the attribute via the DOM 0 way - // 'in' checks fail in Blackberry 4.7 #6931 - if ( (name in elem || elem[ name ] !== undefined) && notxml && !special ) { - if ( set ) { - // We can't allow the type property to be changed (since it causes problems in IE) - if ( name === "type" && rtype.test( elem.nodeName ) && elem.parentNode ) { - jQuery.error( "type property can't be changed" ); - } - - if ( value === null ) { - if ( elem.nodeType === 1 ) { - elem.removeAttribute( name ); - } - - } else { - elem[ name ] = value; - } - } - - // browsers index elements by id/name on forms, give priority to attributes. - if ( jQuery.nodeName( elem, "form" ) && elem.getAttributeNode(name) ) { - return elem.getAttributeNode( name ).nodeValue; - } - - // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set - // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/ - if ( name === "tabIndex" ) { - var attributeNode = elem.getAttributeNode( "tabIndex" ); - - return attributeNode && attributeNode.specified ? - attributeNode.value : - rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ? - 0 : - undefined; - } - + return attributeNode && attributeNode.specified ? + attributeNode.value : + rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ? + 0 : + undefined; + } + } + }, + + // TODO: Check to see if we really need any here. + propFix: {}, + + prop: function( elem, name, value ) { + var ret, hooks; + + // Try to normalize/fix the name + name = notxml && jQuery.propFix[ name ] || name; + + hooks = jQuery.propHooks[ name ]; + + if ( value !== undefined ) { + if ( hooks && "set" in hooks && (ret = hooks.set( elem, value )) !== undefined ) { + return ret; + + } else { + return (elem[ name ] = value); + } + + } else { + if ( hooks && "get" in hooks && (ret = hooks.get( elem )) !== undefined ) { + return ret; + + } else { return elem[ name ]; } - - if ( !jQuery.support.style && notxml && name === "style" ) { - if ( set ) { - elem.style.cssText = "" + value; - } - - return elem.style.cssText; - } - - if ( set ) { - // convert the value to a string (all browsers do this but IE) see #1070 - elem.setAttribute( name, "" + value ); - } - - // Ensure that missing attributes return undefined - // Blackberry 4.7 returns "" from getAttribute #6938 - if ( !elem.attributes[ name ] && (elem.hasAttribute && !elem.hasAttribute( name )) ) { - return undefined; - } - - var attr = !jQuery.support.hrefNormalized && notxml && special ? - // Some attributes require a special call on IE - elem.getAttribute( name, 2 ) : - elem.getAttribute( name ); - - // Non-existent attributes return null, we normalize to undefined - return attr === null ? undefined : attr; } - // Handle everything which isn't a DOM element node - if ( set ) { - elem[ name ] = value; - } - return elem[ name ]; - } + }, + + propHooks: {} }); +// Some attributes require a special call on IE +if ( !jQuery.support.hrefNormalized ) { + jQuery.each([ "href", "src", "style" ], function( i, name ) { + jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], { + get: function( elem ) { + return elem.getAttribute( name, 2 ); + } + }); + }); +} + +if ( !jQuery.support.style ) { + jQuery.attrHooks.style = { + get: function( elem ) { + return elem.style.cssText; + }, + + set: function( elem, value ) { + return (elem.style.cssText = "" + value); + } + }; +} + +// Safari mis-reports the default selected property of an option +// Accessing the parent's selectedIndex property fixes it +if ( !jQuery.support.optSelected ) { + jQuery.attrHooks.selected = { + get: function( elem ) { + var parent = elem.parentNode; + + if ( parent ) { + parent.selectedIndex; + + // Make sure that it also works with optgroups, see #5701 + if ( parent.parentNode ) { + parent.parentNode.selectedIndex; + } + } + } + }; +} + })( jQuery ); From ab4e300919c5b3335e6d6c99ce9b1c314d116f19 Mon Sep 17 00:00:00 2001 From: jeresig Date: Sun, 6 Mar 2011 22:47:40 -0500 Subject: [PATCH 02/42] Very crude first pass at splitting apart the attr/prop logic. Also adding in attrHooks/propHooks. All of it is completely untested. --- src/attributes.js | 274 ++++++++++++++++++++++++++++------------------ 1 file changed, 168 insertions(+), 106 deletions(-) diff --git a/src/attributes.js b/src/attributes.js index 59972105..e5425a05 100644 --- a/src/attributes.js +++ b/src/attributes.js @@ -3,38 +3,37 @@ var rclass = /[\n\t\r]/g, rspaces = /\s+/, rreturn = /\r/g, - rspecialurl = /^(?:href|src|style)$/, rtype = /^(?:button|input)$/i, rfocusable = /^(?:button|input|object|select|textarea)$/i, rclickable = /^a(?:rea)?$/i, rradiocheck = /^(?:radio|checkbox)$/i; -jQuery.props = { - "for": "htmlFor", - "class": "className", - readonly: "readOnly", - maxlength: "maxLength", - cellspacing: "cellSpacing", - rowspan: "rowSpan", - colspan: "colSpan", - tabindex: "tabIndex", - usemap: "useMap", - frameborder: "frameBorder" -}; - jQuery.fn.extend({ attr: function( name, value ) { return jQuery.access( this, name, value, true, jQuery.attr ); }, - removeAttr: function( name, fn ) { - return this.each(function(){ - jQuery.attr( this, name, "" ); + removeAttr: function( name ) { + return this.each(function() { if ( this.nodeType === 1 ) { this.removeAttribute( name ); } }); }, + + prop: function( name, value ) { + return jQuery.access( this, name, value, true, jQuery.prop ); + }, + + removeProp: function( name ) { + return this.each(function() { + // try/catch handles cases where IE balks (such as removing a property on window) + try { + this[ name ] = undefined; + delete this[ name ]; + } catch( e ) {} + }); + }, addClass: function( value ) { if ( jQuery.isFunction(value) ) { @@ -275,6 +274,21 @@ jQuery.extend({ height: true, offset: true }, + + // TODO: Check to see if any of these are needed anymore? + // If not, it may be good to standardize on all-lowercase names instead + attrFix: { + "for": "htmlFor", + "class": "className", + readonly: "readOnly", + maxlength: "maxLength", + cellspacing: "cellSpacing", + rowspan: "rowSpan", + colspan: "colSpan", + tabindex: "tabIndex", + usemap: "useMap", + frameborder: "frameBorder" + }, attr: function( elem, name, value, pass ) { // don't get/set attributes on text, comment and attribute nodes @@ -286,104 +300,152 @@ jQuery.extend({ return jQuery(elem)[name](value); } - var notxml = elem.nodeType !== 1 || !jQuery.isXMLDoc( elem ), - // Whether we are setting (or getting) - set = value !== undefined; - + var ret, + notxml = elem.nodeType !== 1 || !jQuery.isXMLDoc( elem ), + hooks; + // Try to normalize/fix the name - name = notxml && jQuery.props[ name ] || name; + name = notxml && jQuery.attrFix[ name ] || name; + + hooks = jQuery.attrHooks[ name ]; + + if ( value !== undefined ) { + + if ( hooks && "set" in hooks && notxml && (ret = hooks.set( elem, value )) !== undefined ) { + return ret; + + } else { + // convert the value to a string (all browsers do this but IE) see #1070 + value = "" + value; + + elem.setAttribute( name, value ); + + return value; + } + + } else { + + if ( hooks && "get" in hooks && notxml && (ret = hooks.get( elem )) !== undefined ) { + return ret; + + } else { + + if ( !jQuery.hasAttr( elem, name ) ) { + return undefined; + } - // Only do all the following if this is a node (faster for style) - if ( elem.nodeType === 1 ) { - // These attributes require special treatment - var special = rspecialurl.test( name ); + var attr = elem.getAttribute( name ); - // Safari mis-reports the default selected property of an option - // Accessing the parent's selectedIndex property fixes it - if ( name === "selected" && !jQuery.support.optSelected ) { - var parent = elem.parentNode; - if ( parent ) { - parent.selectedIndex; - - // Make sure that it also works with optgroups, see #5701 - if ( parent.parentNode ) { - parent.parentNode.selectedIndex; - } + // Non-existent attributes return null, we normalize to undefined + return attr === null ? + undefined : + attr; + } + } + }, + + hasAttr: function( elem, name ) { + // Blackberry 4.7 returns "" from getAttribute #6938 + return elem.attributes[ name ] || (elem.hasAttribute && elem.hasAttribute( name )); + }, + + attrHooks: { + type: { + set: function( elem, value ) { + // We can't allow the type property to be changed (since it causes problems in IE) + if ( rtype.test( elem.nodeName ) && elem.parentNode ) { + jQuery.error( "type property can't be changed" ); } } + }, + + // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set + // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/ + tabIndex: { + get: function( elem ) { + var attributeNode = elem.getAttributeNode( "tabIndex" ); - // If applicable, access the attribute via the DOM 0 way - // 'in' checks fail in Blackberry 4.7 #6931 - if ( (name in elem || elem[ name ] !== undefined) && notxml && !special ) { - if ( set ) { - // We can't allow the type property to be changed (since it causes problems in IE) - if ( name === "type" && rtype.test( elem.nodeName ) && elem.parentNode ) { - jQuery.error( "type property can't be changed" ); - } - - if ( value === null ) { - if ( elem.nodeType === 1 ) { - elem.removeAttribute( name ); - } - - } else { - elem[ name ] = value; - } - } - - // browsers index elements by id/name on forms, give priority to attributes. - if ( jQuery.nodeName( elem, "form" ) && elem.getAttributeNode(name) ) { - return elem.getAttributeNode( name ).nodeValue; - } - - // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set - // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/ - if ( name === "tabIndex" ) { - var attributeNode = elem.getAttributeNode( "tabIndex" ); - - return attributeNode && attributeNode.specified ? - attributeNode.value : - rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ? - 0 : - undefined; - } - + return attributeNode && attributeNode.specified ? + attributeNode.value : + rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ? + 0 : + undefined; + } + } + }, + + // TODO: Check to see if we really need any here. + propFix: {}, + + prop: function( elem, name, value ) { + var ret, hooks; + + // Try to normalize/fix the name + name = notxml && jQuery.propFix[ name ] || name; + + hooks = jQuery.propHooks[ name ]; + + if ( value !== undefined ) { + if ( hooks && "set" in hooks && (ret = hooks.set( elem, value )) !== undefined ) { + return ret; + + } else { + return (elem[ name ] = value); + } + + } else { + if ( hooks && "get" in hooks && (ret = hooks.get( elem )) !== undefined ) { + return ret; + + } else { return elem[ name ]; } - - if ( !jQuery.support.style && notxml && name === "style" ) { - if ( set ) { - elem.style.cssText = "" + value; - } - - return elem.style.cssText; - } - - if ( set ) { - // convert the value to a string (all browsers do this but IE) see #1070 - elem.setAttribute( name, "" + value ); - } - - // Ensure that missing attributes return undefined - // Blackberry 4.7 returns "" from getAttribute #6938 - if ( !elem.attributes[ name ] && (elem.hasAttribute && !elem.hasAttribute( name )) ) { - return undefined; - } - - var attr = !jQuery.support.hrefNormalized && notxml && special ? - // Some attributes require a special call on IE - elem.getAttribute( name, 2 ) : - elem.getAttribute( name ); - - // Non-existent attributes return null, we normalize to undefined - return attr === null ? undefined : attr; } - // Handle everything which isn't a DOM element node - if ( set ) { - elem[ name ] = value; - } - return elem[ name ]; - } + }, + + propHooks: {} }); +// Some attributes require a special call on IE +if ( !jQuery.support.hrefNormalized ) { + jQuery.each([ "href", "src", "style" ], function( i, name ) { + jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], { + get: function( elem ) { + return elem.getAttribute( name, 2 ); + } + }); + }); +} + +if ( !jQuery.support.style ) { + jQuery.attrHooks.style = { + get: function( elem ) { + return elem.style.cssText; + }, + + set: function( elem, value ) { + return (elem.style.cssText = "" + value); + } + }; +} + +// Safari mis-reports the default selected property of an option +// Accessing the parent's selectedIndex property fixes it +if ( !jQuery.support.optSelected ) { + jQuery.attrHooks.selected = { + get: function( elem ) { + var parent = elem.parentNode; + + if ( parent ) { + parent.selectedIndex; + + // Make sure that it also works with optgroups, see #5701 + if ( parent.parentNode ) { + parent.parentNode.selectedIndex; + } + } + } + }; +} + })( jQuery ); From de79e8c7e0d1d2243447d59c70a9058eabf56bc3 Mon Sep 17 00:00:00 2001 From: timmywil Date: Tue, 8 Mar 2011 12:07:05 -0500 Subject: [PATCH 03/42] Make the new attr/prop changes pass the test suite (in Webkit). There are still errors in IE. + Added hooks for selected, checked, readonly, disabled to removeAttr if set to falsey + Removed all attrs from attrFix, these aren't needed for setAttribute + If prop is used for class, do we want a propFix for class? - We could just assume the user should know to use className with prop. I've done the latter for now. + Created tests for $.fn.prop and $.fn.removeProp - Actually all I did was change broken attr tests to prop where it made sense. --- src/attributes.js | 48 ++++++----- src/manipulation.js | 2 +- test/unit/attributes.js | 177 ++++++++++++++++++++------------------ test/unit/manipulation.js | 6 +- 4 files changed, 124 insertions(+), 109 deletions(-) diff --git a/src/attributes.js b/src/attributes.js index e5425a05..cb8128d2 100644 --- a/src/attributes.js +++ b/src/attributes.js @@ -36,10 +36,10 @@ jQuery.fn.extend({ }, addClass: function( value ) { - if ( jQuery.isFunction(value) ) { + if ( jQuery.isFunction( value ) ) { return this.each(function(i) { var self = jQuery(this); - self.addClass( value.call(this, i, self.attr("class")) ); + self.addClass( value.call(this, i, self.attr("class") || "") ); }); } @@ -278,19 +278,10 @@ jQuery.extend({ // TODO: Check to see if any of these are needed anymore? // If not, it may be good to standardize on all-lowercase names instead attrFix: { - "for": "htmlFor", - "class": "className", - readonly: "readOnly", - maxlength: "maxLength", - cellspacing: "cellSpacing", - rowspan: "rowSpan", - colspan: "colSpan", - tabindex: "tabIndex", - usemap: "useMap", - frameborder: "frameBorder" }, attr: function( elem, name, value, pass ) { + // don't get/set attributes on text, comment and attribute nodes if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || elem.nodeType === 2 ) { return undefined; @@ -314,6 +305,10 @@ jQuery.extend({ if ( hooks && "set" in hooks && notxml && (ret = hooks.set( elem, value )) !== undefined ) { return ret; + } else if ( value === null ) { + elem.removeAttribute( name ); + return undefined; + } else { // convert the value to a string (all browsers do this but IE) see #1070 value = "" + value; @@ -329,7 +324,7 @@ jQuery.extend({ return ret; } else { - + if ( !jQuery.hasAttr( elem, name ) ) { return undefined; } @@ -337,16 +332,14 @@ jQuery.extend({ var attr = elem.getAttribute( name ); // Non-existent attributes return null, we normalize to undefined - return attr === null ? - undefined : - attr; + return attr === null ? undefined : attr; } } }, hasAttr: function( elem, name ) { // Blackberry 4.7 returns "" from getAttribute #6938 - return elem.attributes[ name ] || (elem.hasAttribute && elem.hasAttribute( name )); + return elem && elem.attributes[ name ] || (elem.hasAttribute && elem.hasAttribute( name )); }, attrHooks: { @@ -361,7 +354,7 @@ jQuery.extend({ // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/ - tabIndex: { + tabindex: { get: function( elem ) { var attributeNode = elem.getAttributeNode( "tabIndex" ); @@ -375,10 +368,11 @@ jQuery.extend({ }, // TODO: Check to see if we really need any here. - propFix: {}, + propFix: { + }, prop: function( elem, name, value ) { - var ret, hooks; + var ret, hooks, notxml = elem.nodeType !== 1 || !jQuery.isXMLDoc( elem ); // Try to normalize/fix the name name = notxml && jQuery.propFix[ name ] || name; @@ -406,6 +400,20 @@ jQuery.extend({ propHooks: {} }); +// Remove certain attrs if set to false +jQuery.each([ "selected", "checked", "readonly", "disabled" ], function( i, name ) { + jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], { + set: function( elem, value ) { + if ( !value ) { // '', undefined, false, null will remove attr + elem.removeAttribute( name ); + return false; + } + elem.setAttribute( name, value ); + return value; + } + }); +}); + // Some attributes require a special call on IE if ( !jQuery.support.hrefNormalized ) { jQuery.each([ "href", "src", "style" ], function( i, name ) { diff --git a/src/manipulation.js b/src/manipulation.js index 27f81cc2..81a55cb8 100644 --- a/src/manipulation.js +++ b/src/manipulation.js @@ -377,7 +377,7 @@ function cloneCopyEvent( src, dest ) { } } -function cloneFixAttributes(src, dest) { +function cloneFixAttributes( src, dest ) { // We do not need to do anything for non-Elements if ( dest.nodeType !== 1 ) { return; diff --git a/test/unit/attributes.js b/test/unit/attributes.js index 8cf47bed..d4284556 100644 --- a/test/unit/attributes.js +++ b/test/unit/attributes.js @@ -3,38 +3,64 @@ module("attributes", { teardown: moduleTeardown }); var bareObj = function(value) { return value; }; var functionReturningObj = function(value) { return (function() { return value; }); }; -test("jQuery.props: itegrity test", function() { - - expect(1); - - // This must be maintained and equal jQuery.props - // Ensure that accidental or erroneous property - // overwrites don't occur - // This is simply for better code coverage and future proofing. - var propsShouldBe = { - "for": "htmlFor", - "class": "className", - readonly: "readOnly", - maxlength: "maxLength", - cellspacing: "cellSpacing", - rowspan: "rowSpan", - colspan: "colSpan", - tabindex: "tabIndex", - usemap: "useMap", - frameborder: "frameBorder" - }; - - same(propsShouldBe, jQuery.props, "jQuery.props passes integrity check"); +// test("jQuery.props: integrity test", function() { +// +// expect(1); +// +// // This must be maintained and equal jQuery.props +// // Ensure that accidental or erroneous property +// // overwrites don't occur +// // This is simply for better code coverage and future proofing. +// var propsShouldBe = { +// "for": "htmlFor", +// "class": "className", +// readonly: "readOnly", +// maxlength: "maxLength", +// cellspacing: "cellSpacing", +// rowspan: "rowSpan", +// colspan: "colSpan", +// tabindex: "tabIndex", +// usemap: "useMap", +// frameborder: "frameBorder" +// }; +// +// same(propsShouldBe, jQuery.props, "jQuery.props passes integrity check"); +// +// }); +test("prop", function() { + equals( jQuery('#text1').prop('value'), "Test", 'Check for value attribute' ); + equals( jQuery('#text1').prop('value', "Test2").prop('defaultValue'), "Test", 'Check for defaultValue attribute' ); + equals( jQuery('#select2').prop('selectedIndex'), 3, 'Check for selectedIndex attribute' ); + equals( jQuery('#foo').prop('nodeName').toUpperCase(), 'DIV', 'Check for nodeName attribute' ); + equals( jQuery('#foo').prop('tagName').toUpperCase(), 'DIV', 'Check for tagName attribute' ); + equals( jQuery("