9
9
rnocache = /<(?:script|object|embed|option|style)/i,
10
10
// checked="checked" or checked
11
11
rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
12
rscriptType = /\/(java|ecma)script/i,
13
rcleanScript = /^\s*<!(?:\[CDATA\[|\-\-)/,
13
15
option: [ 1, "<select multiple='multiple'>", "</select>" ],
14
16
legend: [ 1, "<fieldset>", "</fieldset>" ],
378
function cloneFixAttributes(src, dest) {
382
function cloneFixAttributes( src, dest ) {
379
385
// We do not need to do anything for non-Elements
380
386
if ( dest.nodeType !== 1 ) {
384
var nodeName = dest.nodeName.toLowerCase();
386
390
// clearAttributes removes the attributes, which we don't want,
387
391
// but also removes the attachEvent events, which we *do* want
388
dest.clearAttributes();
392
if ( dest.clearAttributes ) {
393
dest.clearAttributes();
390
396
// mergeAttributes, in contrast, only merges back on the
391
397
// original attributes, not the events
392
dest.mergeAttributes(src);
398
if ( dest.mergeAttributes ) {
399
dest.mergeAttributes( src );
402
nodeName = dest.nodeName.toLowerCase();
394
404
// IE6-8 fail to clone children inside object elements that use
395
405
// the proprietary classid attribute value (rather than the type
513
// Used in clean, fixes the defaultChecked property
514
function fixDefaultChecked( elem ) {
515
if ( elem.type === "checkbox" || elem.type === "radio" ) {
516
elem.defaultChecked = elem.checked;
519
// Finds all inputs and passes them to fixDefaultChecked
520
function findInputs( elem ) {
521
if ( jQuery.nodeName( elem, "input" ) ) {
522
fixDefaultChecked( elem );
523
} else if ( elem.getElementsByTagName ) {
524
jQuery.grep( elem.getElementsByTagName("input"), fixDefaultChecked );
505
529
clone: function( elem, dataAndEvents, deepDataAndEvents ) {
506
530
var clone = elem.cloneNode(true),
570
597
// Convert html string into DOM nodes
571
if ( typeof elem === "string" && !rhtml.test( elem ) ) {
572
elem = context.createTextNode( elem );
574
} else if ( typeof elem === "string" ) {
575
// Fix "XHTML"-style tags in all browsers
576
elem = elem.replace(rxhtmlTag, "<$1></$2>");
578
// Trim whitespace, otherwise indexOf won't work as expected
579
var tag = (rtagName.exec( elem ) || ["", ""])[1].toLowerCase(),
580
wrap = wrapMap[ tag ] || wrapMap._default,
582
div = context.createElement("div");
584
// Go to html and back, then peel off extra wrappers
585
div.innerHTML = wrap[1] + elem + wrap[2];
587
// Move to the right depth
592
// Remove IE's autoinserted <tbody> from table fragments
593
if ( !jQuery.support.tbody ) {
595
// String was a <table>, *may* have spurious <tbody>
596
var hasBody = rtbody.test(elem),
597
tbody = tag === "table" && !hasBody ?
598
div.firstChild && div.firstChild.childNodes :
600
// String was a bare <thead> or <tfoot>
601
wrap[1] === "<table>" && !hasBody ?
605
for ( var j = tbody.length - 1; j >= 0 ; --j ) {
606
if ( jQuery.nodeName( tbody[ j ], "tbody" ) && !tbody[ j ].childNodes.length ) {
607
tbody[ j ].parentNode.removeChild( tbody[ j ] );
598
if ( typeof elem === "string" ) {
599
if ( !rhtml.test( elem ) ) {
600
elem = context.createTextNode( elem );
602
// Fix "XHTML"-style tags in all browsers
603
elem = elem.replace(rxhtmlTag, "<$1></$2>");
605
// Trim whitespace, otherwise indexOf won't work as expected
606
var tag = (rtagName.exec( elem ) || ["", ""])[1].toLowerCase(),
607
wrap = wrapMap[ tag ] || wrapMap._default,
609
div = context.createElement("div");
611
// Go to html and back, then peel off extra wrappers
612
div.innerHTML = wrap[1] + elem + wrap[2];
614
// Move to the right depth
619
// Remove IE's autoinserted <tbody> from table fragments
620
if ( !jQuery.support.tbody ) {
622
// String was a <table>, *may* have spurious <tbody>
623
var hasBody = rtbody.test(elem),
624
tbody = tag === "table" && !hasBody ?
625
div.firstChild && div.firstChild.childNodes :
627
// String was a bare <thead> or <tfoot>
628
wrap[1] === "<table>" && !hasBody ?
632
for ( j = tbody.length - 1; j >= 0 ; --j ) {
633
if ( jQuery.nodeName( tbody[ j ], "tbody" ) && !tbody[ j ].childNodes.length ) {
634
tbody[ j ].parentNode.removeChild( tbody[ j ] );
613
// IE completely kills leading whitespace when innerHTML is used
614
if ( !jQuery.support.leadingWhitespace && rleadingWhitespace.test( elem ) ) {
615
div.insertBefore( context.createTextNode( rleadingWhitespace.exec(elem)[0] ), div.firstChild );
618
elem = div.childNodes;
639
// IE completely kills leading whitespace when innerHTML is used
640
if ( !jQuery.support.leadingWhitespace && rleadingWhitespace.test( elem ) ) {
641
div.insertBefore( context.createTextNode( rleadingWhitespace.exec(elem)[0] ), div.firstChild );
644
elem = div.childNodes;
648
// Resets defaultChecked for any radios and checkboxes
649
// about to be appended to the DOM in IE 6/7 (#8060)
651
if ( !jQuery.support.appendChecked ) {
652
if ( elem[0] && typeof (len = elem.length) === "number" ) {
653
for ( j = 0; j < len; j++ ) {
654
findInputs( elem[j] );
621
661
if ( elem.nodeType ) {
628
668
if ( fragment ) {
669
checkScriptType = function( elem ) {
670
return !elem.type || rscriptType.test( elem.type );
629
672
for ( i = 0; ret[i]; i++ ) {
630
673
if ( scripts && jQuery.nodeName( ret[i], "script" ) && (!ret[i].type || ret[i].type.toLowerCase() === "text/javascript") ) {
631
674
scripts.push( ret[i].parentNode ? ret[i].parentNode.removeChild( ret[i] ) : ret[i] );
634
677
if ( ret[i].nodeType === 1 ) {
635
ret.splice.apply( ret, [i + 1, 0].concat(jQuery.makeArray(ret[i].getElementsByTagName("script"))) );
678
var jsTags = jQuery.grep( ret[i].getElementsByTagName( "script" ), checkScriptType );
680
ret.splice.apply( ret, [i + 1, 0].concat( jsTags ) );
637
682
fragment.appendChild( ret[i] );