MCPcopy
hub / github.com/geekape/geek-navigation / domManip

Function domManip

js/jquery.js:5709–5797  ·  view source on GitHub ↗
( collection, args, callback, ignored )

Source from the content-addressed store, hash-verified

5707}
5708
5709function domManip( collection, args, callback, ignored ) {
5710
5711 // Flatten any nested arrays
5712 args = concat.apply( [], args );
5713
5714 var fragment, first, scripts, hasScripts, node, doc,
5715 i = 0,
5716 l = collection.length,
5717 iNoClone = l - 1,
5718 value = args[ 0 ],
5719 isFunction = jQuery.isFunction( value );
5720
5721 // We can't cloneNode fragments that contain checked, in WebKit
5722 if ( isFunction ||
5723 ( l > 1 && typeof value === "string" &&
5724 !support.checkClone && rchecked.test( value ) ) ) {
5725 return collection.each( function( index ) {
5726 var self = collection.eq( index );
5727 if ( isFunction ) {
5728 args[ 0 ] = value.call( this, index, self.html() );
5729 }
5730 domManip( self, args, callback, ignored );
5731 } );
5732 }
5733
5734 if ( l ) {
5735 fragment = buildFragment( args, collection[ 0 ].ownerDocument, false, collection, ignored );
5736 first = fragment.firstChild;
5737
5738 if ( fragment.childNodes.length === 1 ) {
5739 fragment = first;
5740 }
5741
5742 // Require either new content or an interest in ignored elements to invoke the callback
5743 if ( first || ignored ) {
5744 scripts = jQuery.map( getAll( fragment, "script" ), disableScript );
5745 hasScripts = scripts.length;
5746
5747 // Use the original fragment for the last item
5748 // instead of the first because it can end up
5749 // being emptied incorrectly in certain situations (#8070).
5750 for ( ; i < l; i++ ) {
5751 node = fragment;
5752
5753 if ( i !== iNoClone ) {
5754 node = jQuery.clone( node, true, true );
5755
5756 // Keep references to cloned scripts for later restoration
5757 if ( hasScripts ) {
5758
5759 // Support: Android <=4.0 only, PhantomJS 1 only
5760 // push.apply(_, arraylike) throws on ancient WebKit
5761 jQuery.merge( scripts, getAll( node, "script" ) );
5762 }
5763 }
5764
5765 callback.call( collection[ i ], node, i );
5766 }

Callers 1

jquery.jsFile · 0.85

Calls 3

buildFragmentFunction · 0.85
getAllFunction · 0.85
DOMEvalFunction · 0.85

Tested by

no test coverage detected