rem:  if ( f[productfield].selectedIndex == -1 ) { for ( var i = 0 ; i < f[productfield].length ; i++ ) { 
add:    if ( selectedIndex == -1 || !cpts[selectedValue]) { for ( var i = blank ? 1 : 0 ; i < f[productfield].length ; i++ ) { 
context: function selectProduct( f , productfield, componentfield, blank ) {    // this is to avoid handling events that occur before the form    // itself is ready, which happens in buggy browsers.    if ( ( !f ) || ( ! f[productfield] ) ) {        return;    }    // if this is the first load and nothing is selected, no need to    // merge and sort all components; perl gives it to us sorted.    if ( ( first_load ) && ( f[productfield].selectedIndex == -1 ) ) {            first_load = 0;            return;    }    // turn first_load off. this is tricky, since it seems to be    // redundant with the above clause. It's not: if when we first load    // the page there is _one_ element selected, it won't fall into that    // clause, and first_load will remain 1. Then, if we unselect that    // item, selectProduct will be called but the clause will be valid    // (since selectedIndex == -1), and we will return - incorrectly -    // without merge/sorting.    first_load = 0;    // - sel keeps the array of products we are selected.    // - is_diff says if it's a full list or just a list of products that    //   were added to the current selection.    // - single indicates if a single item was selected    var sel = Array();    var is_diff = 0;    var single;    // if nothing selected, pick all    if ( f[productfield].selectedIndex == -1 ) {        for ( var i = 0 ; i < f[productfield].length ; i++ ) {            sel[sel.length] = f[productfield].options[i].value;        }        single = 0;    } else {        for ( i = 0 ; i < f[productfield].length ; i++ ) {            if ( f[productfield].options[i].selected ) {                sel[sel.length] = f[productfield].options[i].value;            }        }        single = ( sel.length == 1 );        // save last_sel before we kill it            var tmp = last_sel;        last_sel = sel;        // this is an optimization: if we've added components, no need        // to remerge them; just merge the new ones with the existing        // options.        if ( ( tmp ) && ( tmp.length < sel.length ) ) {            sel = fake_diff_array(sel, tmp);            is_diff = 1;        }    }    // do the actual fill/update    updateSelect( cpts, sel, f[componentfield], is_diff, single, blank );}
meta: 9421	/local1/tlutelli/issta_data/temp/all_js/javascript/2006_temp/2006/9421/b8e4ba70bb18a7b273351e6f47cf0e9296b43bd9/productmenu.js/buggy/webtools/bugzilla/productmenu.js