Side navigation
Ticket #6341: 0001-Ensure-attr-name-null-works-consistently-across-brow.patch
File 0001-Ensure-attr-name-null-works-consistently-across-brow.patch, 1.7 KB (added by DouglasMeyer, March 24, 2010 11:06AM UTC)
From 2e3905aa43c7678a3d6d436eed90044dcd5397ca Mon Sep 17 00:00:00 2001
From: Douglas Meyer
Date: Tue, 23 Mar 2010 21:50:54 -0500
Subject: [PATCH] Ensure attr('name', null) works consistently across browsers (#6341)
---
src/attributes.js | 6 +++++-
test/unit/attributes.js | 4 +++-
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/src/attributes.js b/src/attributes.js
index aca9e05..2e90112 100644
--- a/src/attributes.js
+++ b/src/attributes.js
@@ -285,7 +285,11 @@ jQuery.extend({
jQuery.error( "type property can't be changed" );
}
- elem[ name ] = value;
+ if (value === null) {
+ elem.removeAttribute( name );
+ } else {
+ elem[ name ] = value;
+ }
}
// browsers index elements by id/name on forms, give priority to attributes.
diff --git a/test/unit/attributes.js b/test/unit/attributes.js
index 21d3d94..c204eff 100644
--- a/test/unit/attributes.js
+++ b/test/unit/attributes.js
@@ -97,7 +97,7 @@ test("attr(Hash)", function() {
});
test("attr(String, Object)", function() {
- expect(23);
+ expect(24);
var div = jQuery("div").attr("foo", "bar"),
fail = false;
for ( var i = 0; i < div.size(); i++ ) {
@@ -113,6 +113,8 @@ test("attr(String, Object)", function() {
jQuery("#name").attr('name', 'something');
equals( jQuery("#name").attr('name'), 'something', 'Set name attribute' );
+ jQuery("#name").attr('title', null);
+ equals( jQuery("#name").attr('title'), '', 'Remove name attribute' );
jQuery("#check2").attr('checked', true);
equals( document.getElementById('check2').checked, true, 'Set checked attribute' );
jQuery("#check2").attr('checked', false);
--
1.6.3.3
Download in other formats:
Original Format
File 0001-Ensure-attr-name-null-works-consistently-across-brow.patch, 1.7 KB (added by DouglasMeyer, March 24, 2010 11:06AM UTC)
From 2e3905aa43c7678a3d6d436eed90044dcd5397ca Mon Sep 17 00:00:00 2001
From: Douglas Meyer
Date: Tue, 23 Mar 2010 21:50:54 -0500
Subject: [PATCH] Ensure attr('name', null) works consistently across browsers (#6341)
---
src/attributes.js | 6 +++++-
test/unit/attributes.js | 4 +++-
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/src/attributes.js b/src/attributes.js
index aca9e05..2e90112 100644
--- a/src/attributes.js
+++ b/src/attributes.js
@@ -285,7 +285,11 @@ jQuery.extend({
jQuery.error( "type property can't be changed" );
}
- elem[ name ] = value;
+ if (value === null) {
+ elem.removeAttribute( name );
+ } else {
+ elem[ name ] = value;
+ }
}
// browsers index elements by id/name on forms, give priority to attributes.
diff --git a/test/unit/attributes.js b/test/unit/attributes.js
index 21d3d94..c204eff 100644
--- a/test/unit/attributes.js
+++ b/test/unit/attributes.js
@@ -97,7 +97,7 @@ test("attr(Hash)", function() {
});
test("attr(String, Object)", function() {
- expect(23);
+ expect(24);
var div = jQuery("div").attr("foo", "bar"),
fail = false;
for ( var i = 0; i < div.size(); i++ ) {
@@ -113,6 +113,8 @@ test("attr(String, Object)", function() {
jQuery("#name").attr('name', 'something');
equals( jQuery("#name").attr('name'), 'something', 'Set name attribute' );
+ jQuery("#name").attr('title', null);
+ equals( jQuery("#name").attr('title'), '', 'Remove name attribute' );
jQuery("#check2").attr('checked', true);
equals( document.getElementById('check2').checked, true, 'Set checked attribute' );
jQuery("#check2").attr('checked', false);
--
1.6.3.3