MCPcopy Create free account
hub / github.com/dtmilano/AndroidViewClient / domManip

Function domManip

docs/_static/jquery-3.6.0.js:6033–6123  ·  view source on GitHub ↗
( collection, args, callback, ignored )

Source from the content-addressed store, hash-verified

6031}
6032
6033function domManip( collection, args, callback, ignored ) {
6034
6035 // Flatten any nested arrays
6036 args = flat( args );
6037
6038 var fragment, first, scripts, hasScripts, node, doc,
6039 i = 0,
6040 l = collection.length,
6041 iNoClone = l - 1,
6042 value = args[ 0 ],
6043 valueIsFunction = isFunction( value );
6044
6045 // We can't cloneNode fragments that contain checked, in WebKit
6046 if ( valueIsFunction ||
6047 ( l > 1 && typeof value === "string" &&
6048 !support.checkClone && rchecked.test( value ) ) ) {
6049 return collection.each( function( index ) {
6050 var self = collection.eq( index );
6051 if ( valueIsFunction ) {
6052 args[ 0 ] = value.call( this, index, self.html() );
6053 }
6054 domManip( self, args, callback, ignored );
6055 } );
6056 }
6057
6058 if ( l ) {
6059 fragment = buildFragment( args, collection[ 0 ].ownerDocument, false, collection, ignored );
6060 first = fragment.firstChild;
6061
6062 if ( fragment.childNodes.length === 1 ) {
6063 fragment = first;
6064 }
6065
6066 // Require either new content or an interest in ignored elements to invoke the callback
6067 if ( first || ignored ) {
6068 scripts = jQuery.map( getAll( fragment, "script" ), disableScript );
6069 hasScripts = scripts.length;
6070
6071 // Use the original fragment for the last item
6072 // instead of the first because it can end up
6073 // being emptied incorrectly in certain situations (#8070).
6074 for ( ; i < l; i++ ) {
6075 node = fragment;
6076
6077 if ( i !== iNoClone ) {
6078 node = jQuery.clone( node, true, true );
6079
6080 // Keep references to cloned scripts for later restoration
6081 if ( hasScripts ) {
6082
6083 // Support: Android <=4.0 only, PhantomJS 1 only
6084 // push.apply(_, arraylike) throws on ancient WebKit
6085 jQuery.merge( scripts, getAll( node, "script" ) );
6086 }
6087 }
6088
6089 callback.call( collection[ i ], node, i );
6090 }

Callers 1

jquery-3.6.0.jsFile · 0.85

Calls 5

isFunctionFunction · 0.85
buildFragmentFunction · 0.85
getAllFunction · 0.85
DOMEvalFunction · 0.85
cloneMethod · 0.80

Tested by

no test coverage detected