MCPcopy
hub / github.com/apache/caldera / domManip

Function domManip

static/jquery/jquery.js:6009–6104  ·  view source on GitHub ↗
( collection, args, callback, ignored )

Source from the content-addressed store, hash-verified

6007}
6008
6009function domManip( collection, args, callback, ignored ) {
6010
6011 // Flatten any nested arrays
6012 args = concat.apply( [], args );
6013
6014 var first, node, hasScripts,
6015 scripts, doc, fragment,
6016 i = 0,
6017 l = collection.length,
6018 iNoClone = l - 1,
6019 value = args[ 0 ],
6020 isFunction = jQuery.isFunction( value );
6021
6022 // We can't cloneNode fragments that contain checked, in WebKit
6023 if ( isFunction ||
6024 ( l > 1 && typeof value === "string" &&
6025 !support.checkClone && rchecked.test( value ) ) ) {
6026 return collection.each( function( index ) {
6027 var self = collection.eq( index );
6028 if ( isFunction ) {
6029 args[ 0 ] = value.call( this, index, self.html() );
6030 }
6031 domManip( self, args, callback, ignored );
6032 } );
6033 }
6034
6035 if ( l ) {
6036 fragment = buildFragment( args, collection[ 0 ].ownerDocument, false, collection, ignored );
6037 first = fragment.firstChild;
6038
6039 if ( fragment.childNodes.length === 1 ) {
6040 fragment = first;
6041 }
6042
6043 // Require either new content or an interest in ignored elements to invoke the callback
6044 if ( first || ignored ) {
6045 scripts = jQuery.map( getAll( fragment, "script" ), disableScript );
6046 hasScripts = scripts.length;
6047
6048 // Use the original fragment for the last item
6049 // instead of the first because it can end up
6050 // being emptied incorrectly in certain situations (#8070).
6051 for ( ; i < l; i++ ) {
6052 node = fragment;
6053
6054 if ( i !== iNoClone ) {
6055 node = jQuery.clone( node, true, true );
6056
6057 // Keep references to cloned scripts for later restoration
6058 if ( hasScripts ) {
6059
6060 // Support: Android<4.1, PhantomJS<2
6061 // push.apply(_, arraylike) throws on ancient WebKit
6062 jQuery.merge( scripts, getAll( node, "script" ) );
6063 }
6064 }
6065
6066 callback.call( collection[ i ], node, i );

Callers 1

jquery.jsFile · 0.85

Calls 5

buildFragmentFunction · 0.85
getAllFunction · 0.85
testMethod · 0.80
replaceMethod · 0.80
applyMethod · 0.45

Tested by

no test coverage detected