MCPcopy Create free account
hub / github.com/TruthHun/BookStack / domManip

Function domManip

static/wangEditor/js/lib/jquery-2.2.1.js:5206–5294  ·  view source on GitHub ↗
( collection, args, callback, ignored )

Source from the content-addressed store, hash-verified

5204}
5205
5206function domManip( collection, args, callback, ignored ) {
5207
5208 // Flatten any nested arrays
5209 args = concat.apply( [], args );
5210
5211 var fragment, first, scripts, hasScripts, node, doc,
5212 i = 0,
5213 l = collection.length,
5214 iNoClone = l - 1,
5215 value = args[ 0 ],
5216 isFunction = jQuery.isFunction( value );
5217
5218 // We can't cloneNode fragments that contain checked, in WebKit
5219 if ( isFunction ||
5220 ( l > 1 && typeof value === "string" &&
5221 !support.checkClone && rchecked.test( value ) ) ) {
5222 return collection.each( function( index ) {
5223 var self = collection.eq( index );
5224 if ( isFunction ) {
5225 args[ 0 ] = value.call( this, index, self.html() );
5226 }
5227 domManip( self, args, callback, ignored );
5228 } );
5229 }
5230
5231 if ( l ) {
5232 fragment = buildFragment( args, collection[ 0 ].ownerDocument, false, collection, ignored );
5233 first = fragment.firstChild;
5234
5235 if ( fragment.childNodes.length === 1 ) {
5236 fragment = first;
5237 }
5238
5239 // Require either new content or an interest in ignored elements to invoke the callback
5240 if ( first || ignored ) {
5241 scripts = jQuery.map( getAll( fragment, "script" ), disableScript );
5242 hasScripts = scripts.length;
5243
5244 // Use the original fragment for the last item
5245 // instead of the first because it can end up
5246 // being emptied incorrectly in certain situations (#8070).
5247 for ( ; i < l; i++ ) {
5248 node = fragment;
5249
5250 if ( i !== iNoClone ) {
5251 node = jQuery.clone( node, true, true );
5252
5253 // Keep references to cloned scripts for later restoration
5254 if ( hasScripts ) {
5255
5256 // Support: Android<4.1, PhantomJS<2
5257 // push.apply(_, arraylike) throws on ancient WebKit
5258 jQuery.merge( scripts, getAll( node, "script" ) );
5259 }
5260 }
5261
5262 callback.call( collection[ i ], node, i );
5263 }

Callers 1

jquery-2.2.1.jsFile · 0.70

Calls 2

buildFragmentFunction · 0.70
getAllFunction · 0.70

Tested by

no test coverage detected