(parent, current, type, templateElement)
| 27650 | } |
| 27651 | |
| 27652 | function addOrReuseElement(parent, current, type, templateElement) { |
| 27653 | var element; |
| 27654 | // Check whether we can reuse the next element |
| 27655 | if (current && lowercase(current.nodeName) === type) { |
| 27656 | // The next element is the right type so reuse it |
| 27657 | element = current; |
| 27658 | } else { |
| 27659 | // The next element is not the right type so create a new one |
| 27660 | element = templateElement.cloneNode(false); |
| 27661 | if (!current) { |
| 27662 | // There are no more elements so just append it to the select |
| 27663 | parent.appendChild(element); |
| 27664 | } else { |
| 27665 | // The next element is not a group so insert the new one |
| 27666 | parent.insertBefore(element, current); |
| 27667 | } |
| 27668 | } |
| 27669 | return element; |
| 27670 | } |
| 27671 | |
| 27672 | |
| 27673 | function removeExcessElements(current) { |
no test coverage detected