jQuery: The Write Less, Do More JavaScript Library

Ticket #1960 (closed enhancement: wontfix)

Opened 9 months ago

Last modified 3 months ago

Name selectors should delegate to document.getElementsByName

Reported by: sil Assigned to: anonymous
Type: enhancement Priority: minor
Milestone: 1.2.4 Component: core
Version: 1.2.1 Keywords:
Cc: Needs: Review

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 (0.5 kB) - added by flesler 4 months ago.
Modification, skips not's
filterByName2.diff (1.8 kB) - added by flesler 4 months ago.
Somewhat shorter, skips not's

Change History

Changed 4 months 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

Changed 4 months ago by joern

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

Changed 4 months ago by flesler

Modification, skips not's

Changed 4 months ago by flesler

Somewhat shorter, skips not's

Changed 4 months 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 :)

Changed 3 months ago by joern

  • status changed from new to closed
  • resolution set to fixed

Fixed in [5343].

Changed 3 months ago by arrix

  • status changed from closed to reopened
  • resolution deleted

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

Changed 3 months ago by flesler

  • status changed from reopened to closed
  • resolution set to wontfix

Right, reverted at [5460], good catch.

Changed 3 months ago by flesler

  • milestone changed from 1.2.2 to 1.2.4
Note: See TracTickets for help on using tickets.