Skip to main content

Bug Tracker

Side navigation

#1960 closed enhancement (wontfix)

Opened November 22, 2007 07:43PM UTC

Closed May 06, 2008 12:13AM UTC

Last modified March 15, 2012 12:44AM UTC

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 (0.5 KB) - added by flesler April 22, 2008 11:57PM UTC.

    Modification, skips not's

  • filterByName2.diff (1.8 KB) - added by flesler April 22, 2008 11:58PM UTC.

    Somewhat shorter, skips not's

Change History (7)

Changed April 22, 2008 09:33PM UTC by flesler comment:1

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 April 22, 2008 10:47PM UTC by joern comment:2

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

Changed April 22, 2008 11:59PM UTC by flesler comment:3

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 April 28, 2008 02:16PM UTC by joern comment:4

resolution: → fixed
status: newclosed

Fixed in [5343].

Changed May 05, 2008 06:01AM UTC by arrix comment:5

resolution: fixed
status: closedreopened

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

Changed May 06, 2008 12:13AM UTC by flesler comment:6

resolution: → wontfix
status: reopenedclosed

Right, reverted at [5460], good catch.

Changed May 13, 2008 05:40PM UTC by flesler comment:7

milestone: 1.2.21.2.4