examples/HTML StarterKit/lib/durandal/js/viewEngine.js
function(allElements){
            if (allElements.length == 1) {
                return allElements[0];
            }

            var withoutCommentsOrEmptyText = [];

            for (var i = 0; i < allElements.length; i++) {
                var current = allElements[i];
                if (current.nodeType != 8) {
                    if (current.nodeType == 3) {
                        var result = /\S/.test(current.nodeValue);
                        if (!result) {
                            continue;
                        }
                    }

                    withoutCommentsOrEmptyText.push(current);
                }
            }

            if (withoutCommentsOrEmptyText.length > 1) {
                return $(withoutCommentsOrEmptyText).wrapAll('<div class="durandal-wrapper"></div>').parent().get(0);
            }

            return withoutCommentsOrEmptyText[0];
        }
function(allElements){
            if (allElements.length == 1) {
                return allElements[0];
            }

            var withoutCommentsOrEmptyText = [];

            for (var i = 0; i < allElements.length; i++) {
                var current = allElements[i];
                if (current.nodeType != 8) {
                    if (current.nodeType == 3) {
                        var result = /\S/.test(current.nodeValue);
                        if (!result) {
                            continue;
                        }
                    }

                    withoutCommentsOrEmptyText.push(current);
                }
            }

            if (withoutCommentsOrEmptyText.length > 1) {
                return $(withoutCommentsOrEmptyText).wrapAll('<div class="durandal-wrapper"></div>').parent().get(0);
            }

            return withoutCommentsOrEmptyText[0];
        }
function ( allElements ) { if ( allElements . length == 1 ) { return allElements [ 0 ] ; } var withoutCommentsOrEmptyText = [ ] ; for ( var i = 0 ; i < allElements . length ; i ++ ) { var current = allElements [ i ] ; if ( current . nodeType != 8 ) { if ( current . nodeType == 3 ) { var result = / \S / . test ( current . nodeValue ) ; if ( ! result ) { continue ; } } withoutCommentsOrEmptyText . push ( current ) ; } } if ( withoutCommentsOrEmptyText . length > 1 ) { return $ ( withoutCommentsOrEmptyText ) . wrapAll ( '<div class="durandal-wrapper"></div>' ) . parent ( ) . get ( 0 ) ; } return withoutCommentsOrEmptyText [ 0 ] ; }
Converts an array of elements into a single element. White space and comments are removed. If a single element does not remain, then the elements are wrapped.
@method ensureSingleElement
@param {DOMElement[]} allElements The elements.
@return {DOMElement} A single element.
Converts an array of elements into a single element . White space and comments are removed . If a single element does not remain then the elements are wrapped .