Skip to main content

Bug Tracker

Side navigation

#2649 closed bug (worksforme)

Opened April 03, 2008 04:25PM UTC

Closed March 18, 2009 03:02AM UTC

Last modified March 14, 2012 05:59AM UTC

Change between jquery 1.2.1 and 1.2.3 on the clone() function causes lag, freezing, and crashes some browsers.

Reported by: pthurmond Owned by:
Priority: major Milestone: 1.2.1
Component: core Version: 1.2.3
Keywords: clone, internet explorer, firefox Cc:
Blocked by: Blocking:
Description

I upgraded to version 1.2.3 to fix a problem that occurs in Internet Explorer 6 and 7.

This problem is when using a function that was written to change the list of select options in one drop down when you select a particular option in another drop down.

I think the problem is caused by the clone() function. But I haven't been able to verify that for sure. I know it only happens in this function that I wrote. I will include my function below.

To be more specific on this, in 1.2.1 it would pause and take up to 90 seconds to finish executing, yet it worked perfectly in Firefox and Safari. Then I upgraded to 1.2.3 and it worked instantly and perfectly in IE7, in IE6 it worked a lot faster, in Safari, Firefox 2, and Firefox 3 Beta 4 it runs slow like IE6 and 7 did while on jquery 1.2.1. In the case of Firefox 3 Beta 5 it straight crashed the browser.

Again I am pretty sure it has to do with the bugfix in Ticket #2184 link: http://dev.jquery.com/ticket/2184

However I haven't been able to narrow it down any further. I have only included the relevant code. The setsel() function works when called by another event without any problems, so the problem is not coming from there. The event is the changing of a select option.

Here is my code...

$(function()
{ 
  // Item class stuff
  $('select.itemclass').change(function()
  {
    var itemnum = this.id.substr(7,1);
    var iclass = this.value;

    classChange(itemnum, iclass);
  });
});

function classChange(itemnum, iclass)
{ 
  newsel = $('tr.hiddenitem select.itemcomm').clone();

  if (iclass)
  {
    // Remove items that don't match the selected frieght class
    newsel.find('option:not(.' + iclass +')').remove();

    // We just removed the blank option, so add it back in
    newsel.prepend("<option value=''></option>");
  } 

  newsel.attr({id: 'riitem' + itemnum}).change(function()
  {
    setsel('riclass' + itemnum, itemclasses[this.value]);
  });

  itd = $('select#riitem' + itemnum).parent();
  itd.empty();
  itd.append(newsel);

  $('#riitem' + itemnum).val('');
}

function setsel(selid,newval)
{
  if (newval == null)
    return null;
  
  if (!newval)
    newval = "";
  
  $('select#' + selid).val(newval);
}
Attachments (0)
Change History (2)

Changed April 04, 2008 05:04AM UTC by davidserduke comment:1

description: I upgraded to version 1.2.3 to fix a problem that occurs in Internet Explorer 6 and 7. \ \ This problem is when using a function that was written to change the list of select options in one drop down when you select a particular option in another drop down. \ \ I think the problem is caused by the clone() function. But I haven't been able to verify that for sure. I know it only happens in this function that I wrote. I will include my function below. \ \ To be more specific on this, in 1.2.1 it would pause and take up to 90 seconds to finish executing, yet it worked perfectly in Firefox and Safari. Then I upgraded to 1.2.3 and it worked instantly and perfectly in IE7, in IE6 it worked a lot faster, in Safari, Firefox 2, and Firefox 3 Beta 4 it runs slow like IE6 and 7 did while on jquery 1.2.1. In the case of Firefox 3 Beta 5 it straight crashed the browser. \ \ Again I am pretty sure it has to do with the bugfix in Ticket #2184 link: http://dev.jquery.com/ticket/2184 \ \ However I haven't been able to narrow it down any further. I have only included the relevant code. The setsel() function works when called by another event without any problems, so the problem is not coming from there. The event is the changing of a select option. \ \ Here is my code... \ $(function() \ { \ // Item class stuff \ $('select.itemclass').change(function() \ { \ var itemnum = this.id.substr(7,1); \ var iclass = this.value; \ \ classChange(itemnum, iclass); \ }); \ }); \ \ function classChange(itemnum, iclass) \ { \ newsel = $('tr.hiddenitem select.itemcomm').clone(); \ \ if (iclass) \ { \ // Remove items that don't match the selected frieght class \ newsel.find('option:not(.' + iclass +')').remove(); \ \ // We just removed the blank option, so add it back in \ newsel.prepend("<option value=''></option>"); \ } \ \ newsel.attr({id: 'riitem' + itemnum}).change(function() \ { \ setsel('riclass' + itemnum, itemclasses[this.value]); \ }); \ \ itd = $('select#riitem' + itemnum).parent(); \ itd.empty(); \ itd.append(newsel); \ \ $('#riitem' + itemnum).val(''); \ } \ \ function setsel(selid,newval) \ { \ if (newval == null) \ return null; \ \ if (!newval) \ newval = ""; \ \ $('select#' + selid).val(newval); \ }I upgraded to version 1.2.3 to fix a problem that occurs in Internet Explorer 6 and 7. \ \ This problem is when using a function that was written to change the list of select options in one drop down when you select a particular option in another drop down. \ \ I think the problem is caused by the clone() function. But I haven't been able to verify that for sure. I know it only happens in this function that I wrote. I will include my function below. \ \ To be more specific on this, in 1.2.1 it would pause and take up to 90 seconds to finish executing, yet it worked perfectly in Firefox and Safari. Then I upgraded to 1.2.3 and it worked instantly and perfectly in IE7, in IE6 it worked a lot faster, in Safari, Firefox 2, and Firefox 3 Beta 4 it runs slow like IE6 and 7 did while on jquery 1.2.1. In the case of Firefox 3 Beta 5 it straight crashed the browser. \ \ Again I am pretty sure it has to do with the bugfix in Ticket #2184 link: http://dev.jquery.com/ticket/2184 \ \ However I haven't been able to narrow it down any further. I have only included the relevant code. The setsel() function works when called by another event without any problems, so the problem is not coming from there. The event is the changing of a select option. \ \ Here is my code... \ {{{ \ $(function() \ { \ // Item class stuff \ $('select.itemclass').change(function() \ { \ var itemnum = this.id.substr(7,1); \ var iclass = this.value; \ \ classChange(itemnum, iclass); \ }); \ }); \ \ function classChange(itemnum, iclass) \ { \ newsel = $('tr.hiddenitem select.itemcomm').clone(); \ \ if (iclass) \ { \ // Remove items that don't match the selected frieght class \ newsel.find('option:not(.' + iclass +')').remove(); \ \ // We just removed the blank option, so add it back in \ newsel.prepend("<option value=''></option>"); \ } \ \ newsel.attr({id: 'riitem' + itemnum}).change(function() \ { \ setsel('riclass' + itemnum, itemclasses[this.value]); \ }); \ \ itd = $('select#riitem' + itemnum).parent(); \ itd.empty(); \ itd.append(newsel); \ \ $('#riitem' + itemnum).val(''); \ } \ \ function setsel(selid,newval) \ { \ if (newval == null) \ return null; \ \ if (!newval) \ newval = ""; \ \ $('select#' + selid).val(newval); \ } \ }}}

It's a bit hard to see in the changeset [4513] but the fix for #2184 was an IE specific change. So it shouldn't have made any difference to firefox, et al. There have been a bunch of other changes to clone since 1.2.1 trying to find a decent solution, so it is still possible clone is the culprit.

Changed March 18, 2009 03:02AM UTC by brandon comment:2

resolution: → worksforme
status: newclosed

Please feel free to reopen if things are still running slow on the latest build of jQuery 1.3.x