Skip to main content

Bug Tracker

Side navigation

#4407 closed enhancement (worksforme)

Opened March 24, 2009 10:48AM UTC

Closed December 24, 2010 04:55AM UTC

Last modified December 24, 2010 04:55AM UTC

Empty selectbox

Reported by: Jorik Owned by:
Priority: major Milestone: 1.3.2
Component: core Version: 1.3.2
Keywords: Cc:
Blocked by: Blocking:
Description

The empty() method on a selectbox is _much_ slower then selectbox.options.length = 0; Maybe it is nice to check if the element is a selectbox, and then use the options.length way to empty the selectbox.

Attachments (1)
  • Untitled-1.html (1.9 KB) - added by jerone March 24, 2009 07:38PM UTC.

    testcase

Change History (6)

Changed March 24, 2009 07:37PM UTC by jerone comment:1

I tested whats faster; the build-in jQuery technick of a while loop and your suggestion of

length=0

Aldo your suggestion is faster then the while loop, it's not the while loop that slows it down; it's the expando management that is the 'problem'.

Changed March 24, 2009 07:41PM UTC by jerone comment:2

My test results in FF:

  • test1: 73ms
  • test2: 1ms
  • test3: 4ms

Changed August 09, 2009 01:42AM UTC by dmethvin comment:3

component: unfilledcore

Changed November 18, 2010 04:07AM UTC by dmethvin comment:4

keywords: → needsreview
status: newopen

We still need to clean off the data attributes. I can't get the test case to work though.

Changed December 24, 2010 04:55AM UTC by dmethvin comment:5

resolution: → worksforme
status: openclosed

The differences don't seem that large to me; I even increased the number of options. For cases where someone is updating large numbers selects at a high frequency and is willing to risk the memory leaks, they can set options.length=0.

http://jsfiddle.net/dmethvin/pm7Y2/

Changed December 24, 2010 04:55AM UTC by dmethvin comment:6

keywords: needsreview