Ticket #3202: SelectBox.patch

File SelectBox.patch, 956 bytes (added by Illogical, 13 years ago)

tried to optimize dom manipulation. needs testing.

  • .js

    old new  
    1212    redisplay: function(id) {
    1313        // Repopulate HTML select box from cache
    1414        var box = document.getElementById(id);
    15         box.options.length = 0; // clear all options
     15        box.innerHTML = ''; // clear all options
     16        var fragment = document.createDocumentFragment();
    1617        for (var i = 0, j = SelectBox.cache[id].length; i < j; i++) {
    1718            var node = SelectBox.cache[id][i];
    1819            if (node.displayed) {
    19                 box.options[box.options.length] = new Option(node.text, node.value, false, false);
     20                fragment.appendChild(new Option(node.text, node.value, false, false));
    2021            }
    2122        }
     23        box.appendChild(fragment.cloneNode(true));
    2224    },
    2325    filter: function(id, text) {
    2426        // Redisplay the HTML select box, displaying only the choices containing ALL
Back to Top