Bug Tracker

Opened 12 years ago

Closed 12 years ago

Last modified 8 years ago

#1960 closed enhancement (wontfix)

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:
Blocked by: Blocking:

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 (2)

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

Download all attachments as: .zip

Change History (9)

comment:1 Changed 12 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 12 years ago by joern

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

Changed 12 years ago by flesler

Attachment: filterByName.diff added

Modification, skips not's

Changed 12 years ago by flesler

Attachment: filterByName2.diff added

Somewhat shorter, skips not's

comment:3 Changed 12 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 12 years ago by joern

Resolution: fixed
Status: newclosed

Fixed in [5343].

comment:5 Changed 12 years ago by arrix

Resolution: fixed
Status: closedreopened

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

comment:6 Changed 12 years ago by flesler

Resolution: wontfix
Status: reopenedclosed

Right, reverted at [5460], good catch.

comment:7 Changed 12 years ago by flesler

Milestone: 1.2.21.2.4
Note: See TracTickets for help on using tickets.