examples/HTML StarterKit/lib/durandal/js/composition.js
function(elements, parts, isReplacementSearch) {
            parts = parts || {};

            if (!elements) {
                return parts;
            }

            if (elements.length === undefined) {
                elements = [elements];
            }

            for (var i = 0, length = elements.length; i < length; i++) {
                var element = elements[i];

                if (element.getAttribute) {
                    if(!isReplacementSearch && hasComposition(element)){
                        continue;
                    }

                    var id = element.getAttribute(partAttributeName);
                    if (id) {
                        parts[id] = element;
                    }

                    if(!isReplacementSearch && element.hasChildNodes()){
                        composition.getParts(element.childNodes, parts);
                    }
                }
            }

            return parts;
        }
function(elements, parts, isReplacementSearch) {
            parts = parts || {};

            if (!elements) {
                return parts;
            }

            if (elements.length === undefined) {
                elements = [elements];
            }

            for (var i = 0, length = elements.length; i < length; i++) {
                var element = elements[i];

                if (element.getAttribute) {
                    if(!isReplacementSearch && hasComposition(element)){
                        continue;
                    }

                    var id = element.getAttribute(partAttributeName);
                    if (id) {
                        parts[id] = element;
                    }

                    if(!isReplacementSearch && element.hasChildNodes()){
                        composition.getParts(element.childNodes, parts);
                    }
                }
            }

            return parts;
        }
function ( elements , parts , isReplacementSearch ) { parts = parts || { } ; if ( ! elements ) { return parts ; } if ( elements . length === undefined ) { elements = [ elements ] ; } for ( var i = 0 , length = elements . length ; i < length ; i ++ ) { var element = elements [ i ] ; if ( element . getAttribute ) { if ( ! isReplacementSearch && hasComposition ( element ) ) { continue ; } var id = element . getAttribute ( partAttributeName ) ; if ( id ) { parts [ id ] = element ; } if ( ! isReplacementSearch && element . hasChildNodes ( ) ) { composition . getParts ( element . childNodes , parts ) ; } } } return parts ; }
Gets an object keyed with all the elements that are replacable parts, found within the supplied elements. The key will be the part name and the value will be the element itself.
@method getParts
@param {DOMElement\DOMElement[]} elements The element(s) to search for parts.
@return {object} An object keyed by part.
Gets an object keyed with all the elements that are replacable parts found within the supplied elements . The key will be the part name and the value will be the element itself .