| @@ 6256-6377 (lines=122) @@ | ||
| 6253 | return clone; |
|
| 6254 | }, |
|
| 6255 | ||
| 6256 | clean: function( elems, context, fragment, scripts ) { |
|
| 6257 | var checkScriptType; |
|
| 6258 | ||
| 6259 | context = context || document; |
|
| 6260 | ||
| 6261 | // !context.createElement fails in IE with an error but returns typeof 'object' |
|
| 6262 | if ( typeof context.createElement === "undefined" ) { |
|
| 6263 | context = context.ownerDocument || context[0] && context[0].ownerDocument || document; |
|
| 6264 | } |
|
| 6265 | ||
| 6266 | var ret = [], j; |
|
| 6267 | ||
| 6268 | for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) { |
|
| 6269 | if ( typeof elem === "number" ) { |
|
| 6270 | elem += ""; |
|
| 6271 | } |
|
| 6272 | ||
| 6273 | if ( !elem ) { |
|
| 6274 | continue; |
|
| 6275 | } |
|
| 6276 | ||
| 6277 | // Convert html string into DOM nodes |
|
| 6278 | if ( typeof elem === "string" ) { |
|
| 6279 | if ( !rhtml.test( elem ) ) { |
|
| 6280 | elem = context.createTextNode( elem ); |
|
| 6281 | } else { |
|
| 6282 | // Fix "XHTML"-style tags in all browsers |
|
| 6283 | elem = elem.replace(rxhtmlTag, "<$1></$2>"); |
|
| 6284 | ||
| 6285 | // Trim whitespace, otherwise indexOf won't work as expected |
|
| 6286 | var tag = ( rtagName.exec( elem ) || ["", ""] )[1].toLowerCase(), |
|
| 6287 | wrap = wrapMap[ tag ] || wrapMap._default, |
|
| 6288 | depth = wrap[0], |
|
| 6289 | div = context.createElement("div"); |
|
| 6290 | ||
| 6291 | // Append wrapper element to unknown element safe doc fragment |
|
| 6292 | if ( context === document ) { |
|
| 6293 | // Use the fragment we've already created for this document |
|
| 6294 | safeFragment.appendChild( div ); |
|
| 6295 | } else { |
|
| 6296 | // Use a fragment created with the owner document |
|
| 6297 | createSafeFragment( context ).appendChild( div ); |
|
| 6298 | } |
|
| 6299 | ||
| 6300 | // Go to html and back, then peel off extra wrappers |
|
| 6301 | div.innerHTML = wrap[1] + elem + wrap[2]; |
|
| 6302 | ||
| 6303 | // Move to the right depth |
|
| 6304 | while ( depth-- ) { |
|
| 6305 | div = div.lastChild; |
|
| 6306 | } |
|
| 6307 | ||
| 6308 | // Remove IE's autoinserted <tbody> from table fragments |
|
| 6309 | if ( !jQuery.support.tbody ) { |
|
| 6310 | ||
| 6311 | // String was a <table>, *may* have spurious <tbody> |
|
| 6312 | var hasBody = rtbody.test(elem), |
|
| 6313 | tbody = tag === "table" && !hasBody ? |
|
| 6314 | div.firstChild && div.firstChild.childNodes : |
|
| 6315 | ||
| 6316 | // String was a bare <thead> or <tfoot> |
|
| 6317 | wrap[1] === "<table>" && !hasBody ? |
|
| 6318 | div.childNodes : |
|
| 6319 | []; |
|
| 6320 | ||
| 6321 | for ( j = tbody.length - 1; j >= 0 ; --j ) { |
|
| 6322 | if ( jQuery.nodeName( tbody[ j ], "tbody" ) && !tbody[ j ].childNodes.length ) { |
|
| 6323 | tbody[ j ].parentNode.removeChild( tbody[ j ] ); |
|
| 6324 | } |
|
| 6325 | } |
|
| 6326 | } |
|
| 6327 | ||
| 6328 | // IE completely kills leading whitespace when innerHTML is used |
|
| 6329 | if ( !jQuery.support.leadingWhitespace && rleadingWhitespace.test( elem ) ) { |
|
| 6330 | div.insertBefore( context.createTextNode( rleadingWhitespace.exec(elem)[0] ), div.firstChild ); |
|
| 6331 | } |
|
| 6332 | ||
| 6333 | elem = div.childNodes; |
|
| 6334 | } |
|
| 6335 | } |
|
| 6336 | ||
| 6337 | // Resets defaultChecked for any radios and checkboxes |
|
| 6338 | // about to be appended to the DOM in IE 6/7 (#8060) |
|
| 6339 | var len; |
|
| 6340 | if ( !jQuery.support.appendChecked ) { |
|
| 6341 | if ( elem[0] && typeof (len = elem.length) === "number" ) { |
|
| 6342 | for ( j = 0; j < len; j++ ) { |
|
| 6343 | findInputs( elem[j] ); |
|
| 6344 | } |
|
| 6345 | } else { |
|
| 6346 | findInputs( elem ); |
|
| 6347 | } |
|
| 6348 | } |
|
| 6349 | ||
| 6350 | if ( elem.nodeType ) { |
|
| 6351 | ret.push( elem ); |
|
| 6352 | } else { |
|
| 6353 | ret = jQuery.merge( ret, elem ); |
|
| 6354 | } |
|
| 6355 | } |
|
| 6356 | ||
| 6357 | if ( fragment ) { |
|
| 6358 | checkScriptType = function( elem ) { |
|
| 6359 | return !elem.type || rscriptType.test( elem.type ); |
|
| 6360 | }; |
|
| 6361 | for ( i = 0; ret[i]; i++ ) { |
|
| 6362 | if ( scripts && jQuery.nodeName( ret[i], "script" ) && (!ret[i].type || ret[i].type.toLowerCase() === "text/javascript") ) { |
|
| 6363 | scripts.push( ret[i].parentNode ? ret[i].parentNode.removeChild( ret[i] ) : ret[i] ); |
|
| 6364 | ||
| 6365 | } else { |
|
| 6366 | if ( ret[i].nodeType === 1 ) { |
|
| 6367 | var jsTags = jQuery.grep( ret[i].getElementsByTagName( "script" ), checkScriptType ); |
|
| 6368 | ||
| 6369 | ret.splice.apply( ret, [i + 1, 0].concat( jsTags ) ); |
|
| 6370 | } |
|
| 6371 | fragment.appendChild( ret[i] ); |
|
| 6372 | } |
|
| 6373 | } |
|
| 6374 | } |
|
| 6375 | ||
| 6376 | return ret; |
|
| 6377 | }, |
|
| 6378 | ||
| 6379 | cleanData: function( elems ) { |
|
| 6380 | var data, id, |
|
| @@ 5493-5585 (lines=93) @@ | ||
| 5490 | // Return the cloned set |
|
| 5491 | return clone; |
|
| 5492 | }, |
|
| 5493 | clean: function( elems, context, fragment, scripts ) { |
|
| 5494 | context = context || document; |
|
| 5495 | ||
| 5496 | // !context.createElement fails in IE with an error but returns typeof 'object' |
|
| 5497 | if ( typeof context.createElement === "undefined" ) { |
|
| 5498 | context = context.ownerDocument || context[0] && context[0].ownerDocument || document; |
|
| 5499 | } |
|
| 5500 | ||
| 5501 | var ret = []; |
|
| 5502 | ||
| 5503 | for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) { |
|
| 5504 | if ( typeof elem === "number" ) { |
|
| 5505 | elem += ""; |
|
| 5506 | } |
|
| 5507 | ||
| 5508 | if ( !elem ) { |
|
| 5509 | continue; |
|
| 5510 | } |
|
| 5511 | ||
| 5512 | // Convert html string into DOM nodes |
|
| 5513 | if ( typeof elem === "string" && !rhtml.test( elem ) ) { |
|
| 5514 | elem = context.createTextNode( elem ); |
|
| 5515 | ||
| 5516 | } else if ( typeof elem === "string" ) { |
|
| 5517 | // Fix "XHTML"-style tags in all browsers |
|
| 5518 | elem = elem.replace(rxhtmlTag, "<$1></$2>"); |
|
| 5519 | ||
| 5520 | // Trim whitespace, otherwise indexOf won't work as expected |
|
| 5521 | var tag = (rtagName.exec( elem ) || ["", ""])[1].toLowerCase(), |
|
| 5522 | wrap = wrapMap[ tag ] || wrapMap._default, |
|
| 5523 | depth = wrap[0], |
|
| 5524 | div = context.createElement("div"); |
|
| 5525 | ||
| 5526 | // Go to html and back, then peel off extra wrappers |
|
| 5527 | div.innerHTML = wrap[1] + elem + wrap[2]; |
|
| 5528 | ||
| 5529 | // Move to the right depth |
|
| 5530 | while ( depth-- ) { |
|
| 5531 | div = div.lastChild; |
|
| 5532 | } |
|
| 5533 | ||
| 5534 | // Remove IE's autoinserted <tbody> from table fragments |
|
| 5535 | if ( !jQuery.support.tbody ) { |
|
| 5536 | ||
| 5537 | // String was a <table>, *may* have spurious <tbody> |
|
| 5538 | var hasBody = rtbody.test(elem), |
|
| 5539 | tbody = tag === "table" && !hasBody ? |
|
| 5540 | div.firstChild && div.firstChild.childNodes : |
|
| 5541 | ||
| 5542 | // String was a bare <thead> or <tfoot> |
|
| 5543 | wrap[1] === "<table>" && !hasBody ? |
|
| 5544 | div.childNodes : |
|
| 5545 | []; |
|
| 5546 | ||
| 5547 | for ( var j = tbody.length - 1; j >= 0 ; --j ) { |
|
| 5548 | if ( jQuery.nodeName( tbody[ j ], "tbody" ) && !tbody[ j ].childNodes.length ) { |
|
| 5549 | tbody[ j ].parentNode.removeChild( tbody[ j ] ); |
|
| 5550 | } |
|
| 5551 | } |
|
| 5552 | ||
| 5553 | } |
|
| 5554 | ||
| 5555 | // IE completely kills leading whitespace when innerHTML is used |
|
| 5556 | if ( !jQuery.support.leadingWhitespace && rleadingWhitespace.test( elem ) ) { |
|
| 5557 | div.insertBefore( context.createTextNode( rleadingWhitespace.exec(elem)[0] ), div.firstChild ); |
|
| 5558 | } |
|
| 5559 | ||
| 5560 | elem = div.childNodes; |
|
| 5561 | } |
|
| 5562 | ||
| 5563 | if ( elem.nodeType ) { |
|
| 5564 | ret.push( elem ); |
|
| 5565 | } else { |
|
| 5566 | ret = jQuery.merge( ret, elem ); |
|
| 5567 | } |
|
| 5568 | } |
|
| 5569 | ||
| 5570 | if ( fragment ) { |
|
| 5571 | for ( i = 0; ret[i]; i++ ) { |
|
| 5572 | if ( scripts && jQuery.nodeName( ret[i], "script" ) && (!ret[i].type || ret[i].type.toLowerCase() === "text/javascript") ) { |
|
| 5573 | scripts.push( ret[i].parentNode ? ret[i].parentNode.removeChild( ret[i] ) : ret[i] ); |
|
| 5574 | ||
| 5575 | } else { |
|
| 5576 | if ( ret[i].nodeType === 1 ) { |
|
| 5577 | ret.splice.apply( ret, [i + 1, 0].concat(jQuery.makeArray(ret[i].getElementsByTagName("script"))) ); |
|
| 5578 | } |
|
| 5579 | fragment.appendChild( ret[i] ); |
|
| 5580 | } |
|
| 5581 | } |
|
| 5582 | } |
|
| 5583 | ||
| 5584 | return ret; |
|
| 5585 | }, |
|
| 5586 | ||
| 5587 | cleanData: function( elems ) { |
|
| 5588 | var data, id, cache = jQuery.cache, internalKey = jQuery.expando, special = jQuery.event.special, |
|