From b40a4807b604efbde51faf075d11e25441af1990 Mon Sep 17 00:00:00 2001 From: Michał Gołębiowski-Owczarek Date: Wed, 31 Jan 2024 01:47:11 +0100 Subject: Attributes: Shave off a couple of bytes The `attrHooks` entries for boolean attributes are only defined for jQuery 4+; jQuery 3.x used a separate mechanism - assigning them to `jQuery.expr.attrHandle`. That object used to be maintained by Sizzle, since jQuery 3.7.0 it's kept in the selector module. Because of that, the `isXMLDoc` check used to be require in this hook. Now that standard `attrHooks` are used, the `isXMLDoc` check already happens inside of `jQuery.attr` and there's no need to repeat it in the test. Note that this repetition is even incorrect - while Sizzle's `jQuery.find.attr` used to treat an `undefined` output of the hooks from `jQuery.expr.attrHandle` as a way to opt out of the hook, jQuery's `attrHooks` use `null` to opt out of a getter hook. Apart from the size, this patch also avoids unnecessary extra checks. Closes gh-5398 --- src/attributes/attr.js | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/attributes/attr.js b/src/attributes/attr.js index 5a911c7d0..426a8e524 100644 --- a/src/attributes/attr.js +++ b/src/attributes/attr.js @@ -108,16 +108,9 @@ jQuery.each( ( ).split( " " ), function( _i, name ) { jQuery.attrHooks[ name ] = { get: function( elem ) { - var ret, - isXML = jQuery.isXMLDoc( elem ), - lowercaseName = name.toLowerCase(); - - if ( !isXML ) { - ret = elem.getAttribute( name ) != null ? - lowercaseName : - null; - } - return ret; + return elem.getAttribute( name ) != null ? + name.toLowerCase() : + null; }, set: function( elem, value, name ) { -- cgit v1.2.3