(parent, current, type, templateElement)
| 27198 | } |
| 27199 | |
| 27200 | function addOrReuseElement(parent, current, type, templateElement) { |
| 27201 | var element; |
| 27202 | // Check whether we can reuse the next element |
| 27203 | if (current && lowercase(current.nodeName) === type) { |
| 27204 | // The next element is the right type so reuse it |
| 27205 | element = current; |
| 27206 | } else { |
| 27207 | // The next element is not the right type so create a new one |
| 27208 | element = templateElement.cloneNode(false); |
| 27209 | if (!current) { |
| 27210 | // There are no more elements so just append it to the select |
| 27211 | parent.appendChild(element); |
| 27212 | } else { |
| 27213 | // The next element is not a group so insert the new one |
| 27214 | parent.insertBefore(element, current); |
| 27215 | } |
| 27216 | } |
| 27217 | return element; |
| 27218 | } |
| 27219 | |
| 27220 | |
| 27221 | function removeExcessElements(current) { |
no test coverage detected