Bug Tracker

Modify

Ticket #10463 (closed enhancement: patchwelcome)

Opened 20 months ago

Last modified 11 months ago

RemoveAttr should check if attribute exist (when it's possible) before remove it

Reported by: markel Owned by: markel
Priority: low Milestone: None
Component: attributes Version: 1.7b1
Keywords: Cc:
Blocking: Blocked by:

Description

You already have similar behavior in removeClass method, without it you would got something like this --  http://jsperf.com/removeclass-without-check-for-classname-attr

Of course in removeClass that check needed for other reasons too, but in some cases it will improve performance for removeAttr.

Fast --  http://jsperf.com/removeattr-with-check-for-attr

Less faster --  http://jsperf.com/removeattr-with-check-for-attr-2

Equally fast or little bit slower --  http://jsperf.com/removeattr-with-check-for-attr-3

Pull request --  https://github.com/jquery/jquery/pull/538

Change History

comment:1 Changed 20 months ago by rwaldron

  • Owner set to markel
  • Priority changed from undecided to low
  • Status changed from new to pending
  • Component changed from unfiled to attributes

Strike that, I misread the test

Last edited 20 months ago by rwaldron (previous) (diff)

comment:2 follow-up: ↓ 3 Changed 20 months ago by markel

  • Status changed from pending to new

First show how speed will improve without attributes, is no need for attribute to exist -- its hole point Second shows if one attribute exist and another is not, its add only one attribute every time Third remove and immediately add the same attribute, so every time its will remove attribute

Please look more closely, they not bogus.

comment:3 in reply to: ↑ 2 Changed 20 months ago by rwaldron

I think you missed my edit...

Replying to markel:

First show how speed will improve without attributes, is no need for attribute to exist -- its hole point Second shows if one attribute exist and another is not, its add only one attribute every time Third remove and immediately add the same attribute, so every time its will remove attribute

Please look more closely, they not bogus.

comment:4 Changed 20 months ago by markel

yeah, i see now

comment:5 Changed 19 months ago by timmywil

  • Status changed from new to open

comment:6 Changed 11 months ago by dmethvin

  • Status changed from open to closed
  • Resolution set to patchwelcome

They both seem fast enough, but if you want to resurrect this submit let us know and we can discuss for 1.9.

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.