Bug Tracker

Modify

Ticket #1960 (closed enhancement: wontfix)

Opened 6 years ago

Last modified 15 months ago

Name selectors should delegate to document.getElementsByName

Reported by: sil Owned by:
Priority: minor Milestone: 1.2.4
Component: core Version: 1.2.1
Keywords: Cc:
Blocking: Blocked by:

Description

The selector $("*[@name=foo]") should delegate to document.getElementsByName("foo"), since getElementsByName is natively implemented and therefore faster. (This assumes that you can recognise this selector type fast enough that it's worth checking for it to do the delegation, of course.)

Attachments

filterByName.diff Download (559 bytes) - added by flesler 5 years ago.
Modification, skips not's
filterByName2.diff Download (1.8 KB) - added by flesler 5 years ago.
Somewhat shorter, skips not's

Change History

comment:1 Changed 5 years ago by flesler

I did a quick benchmark, the page had 533 elements, 7 of them matched the name. The call was

$('[name=foo]');

Results:

IE 6
   1. normal : 3297ms
   2. normal : 3281ms
   3. normal : 3281ms
   4. normal : 3297ms
   5. normal : 3281ms
   6. normal : average : 3287.4ms
   7. normal : minimum : 3281ms
   8. optimized : 813ms
   9. optimized : 797ms
   10. optimized : 812ms
   11. optimized : 828ms
   12. optimized : 813ms
   13. optimized : average : 812.6ms
   14. optimized : minimum : 797ms

 Firefox 2(no firebug)
   1. normal : 3265ms
   2. normal : 3172ms
   3. normal : 3218ms
   4. normal : 3219ms
   5. normal : 3141ms
   6. normal : average : 3203ms
   7. normal : minimum : 3141ms
   8. optimized : 468ms
   9. optimized : 469ms
  10. optimized : 468ms
  11. optimized : 469ms
  12. optimized : 468ms
  13. optimized : average : 468.4ms
  14. optimized : minimum : 468ms

comment:2 Changed 5 years ago by joern

Both patches break "selector module: attributes" test 19. and 20., related to :not()

Changed 5 years ago by flesler

Modification, skips not's

Changed 5 years ago by flesler

Somewhat shorter, skips not's

comment:3 Changed 5 years ago by flesler

I made a few attempts but it just fails when doing :not. I restricted it to only positive filters, see if this passes, I g2g, I'll try to test this myself :)

comment:4 Changed 5 years ago by joern

  • Status changed from new to closed
  • Resolution set to fixed

Fixed in [5343].

comment:5 Changed 5 years ago by arrix

  • Status changed from closed to reopened
  • Resolution fixed deleted

document.getElementsByName can only retrieve elements in the document tree. see #2787

comment:6 Changed 5 years ago by flesler

  • Status changed from reopened to closed
  • Resolution set to wontfix

Right, reverted at [5460], good catch.

comment:7 Changed 5 years ago by flesler

  • Milestone changed from 1.2.2 to 1.2.4

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.