From ca2ec4e4415d55ae26418e0b8f594541ab0e174b Mon Sep 17 00:00:00 2001 From: Mike Pennisi Date: Sat, 19 Dec 2015 15:33:53 -0500 Subject: [PATCH 1/3] attr: Document attr(key, null) to remove attribute In addition, introduce the `null` value type to more completely describe the `attr` method's signature. jQuery implements explicit support for this behavior [1]: if ( value === null ) { jQuery.removeAttr( elem, name ); return; } and also maintains unit tests to verify it [2]: jQuery( "#name" ).attr( "name", null ); assert.equal( jQuery( "#name" ).attr( "name" ), undefined, "Remove name attribute" ); Fixes gh-523 [1] https://github.com/jquery/jquery/blob/1823a715660a5f31dd7e05672e9ad020066256a9/src/attributes/attr.js#L55-L58 [2] https://github.com/jquery/jquery/blob/1823a715660a5f31dd7e05672e9ad020066256a9/test/unit/attributes.js#L283-L284 --- entries/attr.xml | 3 ++- pages/Types.html | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/entries/attr.xml b/entries/attr.xml index 203c61c8..fb010e19 100644 --- a/entries/attr.xml +++ b/entries/attr.xml @@ -147,7 +147,8 @@ The title of the emphasis is:
- A value to set for the attribute. + + A value to set for the attribute. If null, the specified attribute will be removed (as in .removeAttr()). diff --git a/pages/Types.html b/pages/Types.html index fbf2bf80..643ce6f2 100644 --- a/pages/Types.html +++ b/pages/Types.html @@ -432,6 +432,9 @@

PlainObject

jQuery.isPlainObject( o ); // true +

Null

+

The null keyword is a JavaScript literal that is commonly used to signal the absence of an intentional value.

+

Date

The Date type is a JavaScript object that represents a single moment in time. Date objects are instantiated using their constructor function, which by default creates an object that represents the current date and time.

From 4825f13fbf78a87154ba24fee482f77db5adf1e7 Mon Sep 17 00:00:00 2001 From: Mike Pennisi Date: Sun, 20 Dec 2015 17:00:00 -0500 Subject: [PATCH 2/3] fixup! attr: Document attr(key, null) to remove attribute --- entries/attr.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entries/attr.xml b/entries/attr.xml index fb010e19..40c94de1 100644 --- a/entries/attr.xml +++ b/entries/attr.xml @@ -148,7 +148,7 @@ The title of the emphasis is:
- A value to set for the attribute. If null, the specified attribute will be removed (as in .removeAttr()). + A value to set for the attribute. If null, the specified attribute will be removed (as in .removeAttr()).
From 4643f7c44a171fe08c3e5d5a6a85d50656345773 Mon Sep 17 00:00:00 2001 From: Mike Pennisi Date: Sun, 20 Dec 2015 17:01:13 -0500 Subject: [PATCH 3/3] fixup! attr: Document attr(key, null) to remove attribute --- pages/Types.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pages/Types.html b/pages/Types.html index 643ce6f2..4890df38 100644 --- a/pages/Types.html +++ b/pages/Types.html @@ -433,7 +433,7 @@

PlainObject

Null

-

The null keyword is a JavaScript literal that is commonly used to signal the absence of an intentional value.

+

The null keyword is a JavaScript literal that is commonly used to express the absence of an intentional value.

Date

The Date type is a JavaScript object that represents a single moment in time. Date objects are instantiated using their constructor function, which by default creates an object that represents the current date and time.