2013-09-09 15:26:21 +00:00
|
|
|
// Require more than a few needed variables
|
|
|
|
// Keep in mind that a dependency array cannot be used with CommonJS+AMD syntax
|
|
|
|
define(function( require ){
|
|
|
|
|
2011-09-28 15:39:05 +00:00
|
|
|
function createSafeFragment( document ) {
|
2011-11-08 02:22:04 +00:00
|
|
|
var list = nodeNames.split( "|" ),
|
2012-10-26 00:41:47 +00:00
|
|
|
safeFrag = document.createDocumentFragment();
|
2011-09-28 15:39:05 +00:00
|
|
|
|
|
|
|
if ( safeFrag.createElement ) {
|
2011-10-23 20:07:07 +00:00
|
|
|
while ( list.length ) {
|
2011-09-28 15:39:05 +00:00
|
|
|
safeFrag.createElement(
|
2011-10-23 20:07:07 +00:00
|
|
|
list.pop()
|
2011-09-28 15:39:05 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return safeFrag;
|
|
|
|
}
|
|
|
|
|
2013-09-09 15:26:21 +00:00
|
|
|
var
|
|
|
|
jQuery = require( "./core" ),
|
|
|
|
strundefined = require( "./var/strundefined" ),
|
|
|
|
concat = require( "./var/concat" ),
|
|
|
|
push = require( "./var/push" ),
|
|
|
|
deletedIds = require( "./var/deletedIds" ),
|
|
|
|
access = require( "./core/access" ),
|
|
|
|
rcheckableType = require( "./manipulation/var/rcheckableType" ),
|
|
|
|
support = require( "./manipulation/support" ),
|
|
|
|
|
|
|
|
nodeNames = "abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|" +
|
2011-11-08 02:22:04 +00:00
|
|
|
"header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",
|
2012-07-23 02:23:32 +00:00
|
|
|
rinlinejQuery = / jQuery\d+="(?:null|\d+)"/g,
|
2012-11-26 08:20:43 +00:00
|
|
|
rnoshimcache = new RegExp("<(?:" + nodeNames + ")[\\s/>]", "i"),
|
2009-07-19 15:48:30 +00:00
|
|
|
rleadingWhitespace = /^\s+/,
|
2013-09-09 15:26:21 +00:00
|
|
|
|
2012-06-16 01:01:44 +00:00
|
|
|
rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,
|
2009-10-12 16:26:01 +00:00
|
|
|
rtagName = /<([\w:]+)/,
|
2009-07-19 15:57:43 +00:00
|
|
|
rtbody = /<tbody/i,
|
2010-02-06 00:58:08 +00:00
|
|
|
rhtml = /<|&#?\w+;/,
|
2012-04-05 16:12:38 +00:00
|
|
|
rnoInnerhtml = /<(?:script|style|link)/i,
|
2011-01-24 10:18:57 +00:00
|
|
|
// checked="checked" or checked
|
2010-11-09 15:34:32 +00:00
|
|
|
rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
|
2012-11-19 14:50:19 +00:00
|
|
|
rscriptType = /^$|\/(?:java|ecma)script/i,
|
|
|
|
rscriptTypeMasked = /^true\/(.*)/,
|
2012-11-26 08:20:43 +00:00
|
|
|
rcleanScript = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g,
|
2013-01-13 19:46:50 +00:00
|
|
|
|
|
|
|
// We have to close these tags to support XHTML (#13200)
|
2009-09-07 20:55:36 +00:00
|
|
|
wrapMap = {
|
2013-01-13 17:45:52 +00:00
|
|
|
option: [ 1, "<select multiple='multiple'>", "</select>" ],
|
|
|
|
legend: [ 1, "<fieldset>", "</fieldset>" ],
|
|
|
|
area: [ 1, "<map>", "</map>" ],
|
|
|
|
param: [ 1, "<object>", "</object>" ],
|
|
|
|
thead: [ 1, "<table>", "</table>" ],
|
|
|
|
tr: [ 2, "<table><tbody>", "</tbody></table>" ],
|
|
|
|
col: [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ],
|
|
|
|
td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
|
2012-11-21 03:57:41 +00:00
|
|
|
|
|
|
|
// IE6-8 can't serialize link, script, style, or any html5 (NoScope) tags,
|
|
|
|
// unless wrapped in a div with non-breaking characters in front of it.
|
2013-09-02 17:21:09 +00:00
|
|
|
_default: support.htmlSerialize ? [ 0, "", "" ] : [ 1, "X<div>", "</div>" ]
|
2011-09-19 20:42:36 +00:00
|
|
|
},
|
2012-04-17 01:57:41 +00:00
|
|
|
safeFragment = createSafeFragment( document ),
|
2012-11-21 03:57:41 +00:00
|
|
|
fragmentDiv = safeFragment.appendChild( document.createElement("div") );
|
2009-07-19 15:48:30 +00:00
|
|
|
|
2009-09-07 20:55:36 +00:00
|
|
|
wrapMap.optgroup = wrapMap.option;
|
|
|
|
wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
|
|
|
|
wrapMap.th = wrapMap.td;
|
|
|
|
|
2013-09-10 00:13:01 +00:00
|
|
|
// Dependencies not needed as variables
|
|
|
|
require( "./core/init" );
|
|
|
|
require( "./data/accepts" );
|
|
|
|
require( "./traversing" );
|
|
|
|
require( "./selector" );
|
|
|
|
require( "./event" );
|
2011-12-06 20:25:38 +00:00
|
|
|
|
2013-09-09 16:22:37 +00:00
|
|
|
function getAll( context, tag ) {
|
|
|
|
var elems, elem,
|
|
|
|
i = 0,
|
|
|
|
found = typeof context.getElementsByTagName !== strundefined ? context.getElementsByTagName( tag || "*" ) :
|
|
|
|
typeof context.querySelectorAll !== strundefined ? context.querySelectorAll( tag || "*" ) :
|
|
|
|
undefined;
|
2010-02-02 02:48:05 +00:00
|
|
|
|
2013-09-09 16:22:37 +00:00
|
|
|
if ( !found ) {
|
|
|
|
for ( found = [], elems = context.childNodes || context; (elem = elems[i]) != null; i++ ) {
|
|
|
|
if ( !tag || jQuery.nodeName( elem, tag ) ) {
|
|
|
|
found.push( elem );
|
|
|
|
} else {
|
|
|
|
jQuery.merge( found, getAll( elem, tag ) );
|
2013-04-03 17:17:02 +00:00
|
|
|
}
|
2009-07-19 15:48:30 +00:00
|
|
|
}
|
2013-09-09 16:22:37 +00:00
|
|
|
}
|
2009-07-11 13:49:46 +00:00
|
|
|
|
2013-09-09 16:22:37 +00:00
|
|
|
return tag === undefined || tag && jQuery.nodeName( context, tag ) ?
|
|
|
|
jQuery.merge( [ context ], found ) :
|
|
|
|
found;
|
|
|
|
}
|
2009-03-18 21:15:38 +00:00
|
|
|
|
2013-09-09 16:22:37 +00:00
|
|
|
// Used in buildFragment, fixes the defaultChecked property
|
|
|
|
function fixDefaultChecked( elem ) {
|
|
|
|
if ( rcheckableType.test( elem.type ) ) {
|
|
|
|
elem.defaultChecked = elem.checked;
|
2009-03-18 21:15:38 +00:00
|
|
|
}
|
2013-09-09 16:22:37 +00:00
|
|
|
}
|
2009-03-18 21:15:38 +00:00
|
|
|
|
2013-04-03 17:17:02 +00:00
|
|
|
// Support: IE<8
|
|
|
|
// Manipulating tables requires a tbody
|
|
|
|
function manipulationTarget( elem, content ) {
|
|
|
|
return jQuery.nodeName( elem, "table" ) &&
|
|
|
|
jQuery.nodeName( content.nodeType === 1 ? content : content.firstChild, "tr" ) ?
|
|
|
|
|
|
|
|
elem.getElementsByTagName("tbody")[0] ||
|
|
|
|
elem.appendChild( elem.ownerDocument.createElement("tbody") ) :
|
|
|
|
elem;
|
2010-03-02 02:24:49 +00:00
|
|
|
}
|
|
|
|
|
2012-11-19 14:50:19 +00:00
|
|
|
// Replace/restore the type attribute of script elements for safe DOM manipulation
|
|
|
|
function disableScript( elem ) {
|
2013-04-18 18:00:13 +00:00
|
|
|
elem.type = (jQuery.find.attr( elem, "type" ) !== null) + "/" + elem.type;
|
2012-11-19 14:50:19 +00:00
|
|
|
return elem;
|
|
|
|
}
|
|
|
|
function restoreScript( elem ) {
|
|
|
|
var match = rscriptTypeMasked.exec( elem.type );
|
|
|
|
if ( match ) {
|
|
|
|
elem.type = match[1];
|
|
|
|
} else {
|
|
|
|
elem.removeAttribute("type");
|
|
|
|
}
|
|
|
|
return elem;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Mark scripts as having already been evaluated
|
|
|
|
function setGlobalEval( elems, refElements ) {
|
|
|
|
var elem,
|
|
|
|
i = 0;
|
|
|
|
for ( ; (elem = elems[i]) != null; i++ ) {
|
|
|
|
jQuery._data( elem, "globalEval", !refElements || jQuery._data( refElements[i], "globalEval" ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-20 19:25:56 +00:00
|
|
|
function cloneCopyEvent( src, dest ) {
|
2009-12-02 22:15:09 +00:00
|
|
|
|
2011-01-20 19:25:56 +00:00
|
|
|
if ( dest.nodeType !== 1 || !jQuery.hasData( src ) ) {
|
|
|
|
return;
|
|
|
|
}
|
2010-12-22 15:13:28 +00:00
|
|
|
|
2011-09-19 20:13:14 +00:00
|
|
|
var type, i, l,
|
|
|
|
oldData = jQuery._data( src ),
|
|
|
|
curData = jQuery._data( dest, oldData ),
|
|
|
|
events = oldData.events;
|
|
|
|
|
|
|
|
if ( events ) {
|
|
|
|
delete curData.handle;
|
|
|
|
curData.events = {};
|
|
|
|
|
|
|
|
for ( type in events ) {
|
|
|
|
for ( i = 0, l = events[ type ].length; i < l; i++ ) {
|
2012-01-28 19:58:00 +00:00
|
|
|
jQuery.event.add( dest, type, events[ type ][ i ] );
|
2009-12-22 17:04:17 +00:00
|
|
|
}
|
|
|
|
}
|
2011-01-20 19:25:56 +00:00
|
|
|
}
|
2011-09-19 20:13:14 +00:00
|
|
|
|
|
|
|
// make the cloned public data object a copy from the original
|
|
|
|
if ( curData.data ) {
|
|
|
|
curData.data = jQuery.extend( {}, curData.data );
|
|
|
|
}
|
2009-12-02 22:15:09 +00:00
|
|
|
}
|
|
|
|
|
2012-11-18 22:03:38 +00:00
|
|
|
function fixCloneNodeIssues( src, dest ) {
|
2013-01-29 00:04:58 +00:00
|
|
|
var nodeName, e, data;
|
2011-04-22 01:51:23 +00:00
|
|
|
|
2010-12-13 01:23:22 +00:00
|
|
|
// We do not need to do anything for non-Elements
|
|
|
|
if ( dest.nodeType !== 1 ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-11-18 18:53:24 +00:00
|
|
|
nodeName = dest.nodeName.toLowerCase();
|
2010-12-13 01:23:22 +00:00
|
|
|
|
2012-11-18 18:53:24 +00:00
|
|
|
// IE6-8 copies events bound via attachEvent when using cloneNode.
|
2013-09-02 17:21:09 +00:00
|
|
|
if ( !support.noCloneEvent && dest[ jQuery.expando ] ) {
|
2012-11-18 18:53:24 +00:00
|
|
|
data = jQuery._data( dest );
|
2010-12-13 01:23:22 +00:00
|
|
|
|
2012-11-18 18:53:24 +00:00
|
|
|
for ( e in data.events ) {
|
|
|
|
jQuery.removeEvent( dest, e, data.handle );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Event data gets referenced instead of copied if the expando gets copied too
|
|
|
|
dest.removeAttribute( jQuery.expando );
|
|
|
|
}
|
2011-04-22 01:51:23 +00:00
|
|
|
|
2012-11-19 14:50:19 +00:00
|
|
|
// IE blanks contents when cloning scripts, and tries to evaluate newly-set text
|
|
|
|
if ( nodeName === "script" && dest.text !== src.text ) {
|
|
|
|
disableScript( dest ).text = src.text;
|
|
|
|
restoreScript( dest );
|
|
|
|
|
|
|
|
// IE6-10 improperly clones children of object elements using classid.
|
|
|
|
// IE10 throws NoModificationAllowedError if parent is null, #12132.
|
|
|
|
} else if ( nodeName === "object" ) {
|
2012-07-24 18:34:14 +00:00
|
|
|
if ( dest.parentNode ) {
|
|
|
|
dest.outerHTML = src.outerHTML;
|
|
|
|
}
|
2010-12-13 01:23:22 +00:00
|
|
|
|
2012-03-23 15:31:53 +00:00
|
|
|
// This path appears unavoidable for IE9. When cloning an object
|
|
|
|
// element in IE9, the outerHTML strategy above is not sufficient.
|
|
|
|
// If the src has innerHTML and the destination does not,
|
|
|
|
// copy the src.innerHTML into the dest.innerHTML. #10324
|
2013-09-02 17:21:09 +00:00
|
|
|
if ( support.html5Clone && ( src.innerHTML && !jQuery.trim(dest.innerHTML) ) ) {
|
2012-03-23 15:31:53 +00:00
|
|
|
dest.innerHTML = src.innerHTML;
|
|
|
|
}
|
2012-04-11 01:38:11 +00:00
|
|
|
|
2013-08-15 18:15:49 +00:00
|
|
|
} else if ( nodeName === "input" && rcheckableType.test( src.type ) ) {
|
2011-01-10 00:38:44 +00:00
|
|
|
// IE6-8 fails to persist the checked state of a cloned checkbox
|
|
|
|
// or radio button. Worse, IE6-7 fail to give the cloned element
|
|
|
|
// a checked appearance if the defaultChecked value isn't also set
|
2012-07-26 02:23:24 +00:00
|
|
|
|
2013-09-09 16:22:37 +00:00
|
|
|
dest.defaultChecked = dest.checked = src.checked;
|
|
|
|
|
|
|
|
// IE6-7 get confused and end up setting the value of a cloned
|
|
|
|
// checkbox/radio button to an empty string instead of "on"
|
|
|
|
if ( dest.value !== src.value ) {
|
|
|
|
dest.value = src.value;
|
2012-11-19 14:50:19 +00:00
|
|
|
}
|
|
|
|
|
2013-09-09 16:22:37 +00:00
|
|
|
// IE6-8 fails to return the selected option to the default selected
|
|
|
|
// state when cloning options
|
|
|
|
} else if ( nodeName === "option" ) {
|
|
|
|
dest.defaultSelected = dest.selected = src.defaultSelected;
|
2011-02-23 18:18:44 +00:00
|
|
|
|
2013-09-09 16:22:37 +00:00
|
|
|
// IE6-8 fails to set the defaultValue to the correct value when
|
|
|
|
// cloning other types of input fields
|
|
|
|
} else if ( nodeName === "input" || nodeName === "textarea" ) {
|
|
|
|
dest.defaultValue = src.defaultValue;
|
2011-04-22 01:51:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-03-18 21:15:38 +00:00
|
|
|
jQuery.extend({
|
2011-01-20 20:25:04 +00:00
|
|
|
clone: function( elem, dataAndEvents, deepDataAndEvents ) {
|
2013-01-29 00:04:58 +00:00
|
|
|
var destElements, node, clone, i, srcElements,
|
2012-11-19 14:50:19 +00:00
|
|
|
inPage = jQuery.contains( elem.ownerDocument, elem );
|
2012-04-17 01:57:41 +00:00
|
|
|
|
2013-09-02 17:21:09 +00:00
|
|
|
if ( support.html5Clone || jQuery.isXMLDoc(elem) || !rnoshimcache.test( "<" + elem.nodeName + ">" ) ) {
|
2012-08-08 20:31:59 +00:00
|
|
|
clone = elem.cloneNode( true );
|
2012-11-18 22:03:38 +00:00
|
|
|
|
2012-04-17 01:57:41 +00:00
|
|
|
// IE<=8 does not properly clone detached, unknown element nodes
|
|
|
|
} else {
|
|
|
|
fragmentDiv.innerHTML = elem.outerHTML;
|
|
|
|
fragmentDiv.removeChild( clone = fragmentDiv.firstChild );
|
|
|
|
}
|
2011-01-20 19:25:56 +00:00
|
|
|
|
2013-09-02 17:21:09 +00:00
|
|
|
if ( (!support.noCloneEvent || !support.noCloneChecked) &&
|
2011-02-23 18:18:44 +00:00
|
|
|
(elem.nodeType === 1 || elem.nodeType === 11) && !jQuery.isXMLDoc(elem) ) {
|
2011-01-20 19:25:56 +00:00
|
|
|
|
2012-11-19 14:50:19 +00:00
|
|
|
// We eschew Sizzle here for performance reasons: http://jsperf.com/getall-vs-sizzle/2
|
2011-02-23 18:18:44 +00:00
|
|
|
destElements = getAll( clone );
|
2012-11-19 14:50:19 +00:00
|
|
|
srcElements = getAll( elem );
|
2011-01-20 19:25:56 +00:00
|
|
|
|
2012-11-18 18:53:24 +00:00
|
|
|
// Fix all IE cloning issues
|
2012-11-19 14:50:19 +00:00
|
|
|
for ( i = 0; (node = srcElements[i]) != null; ++i ) {
|
2011-06-15 15:14:52 +00:00
|
|
|
// Ensure that the destination node is not null; Fixes #9587
|
|
|
|
if ( destElements[i] ) {
|
2012-11-18 22:03:38 +00:00
|
|
|
fixCloneNodeIssues( node, destElements[i] );
|
2011-06-15 15:14:52 +00:00
|
|
|
}
|
2011-01-20 19:25:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Copy the events from the original to the clone
|
2011-01-20 20:25:04 +00:00
|
|
|
if ( dataAndEvents ) {
|
2011-02-23 18:18:44 +00:00
|
|
|
if ( deepDataAndEvents ) {
|
2012-11-18 18:53:24 +00:00
|
|
|
srcElements = srcElements || getAll( elem );
|
|
|
|
destElements = destElements || getAll( clone );
|
2011-01-20 19:25:56 +00:00
|
|
|
|
2012-11-19 14:50:19 +00:00
|
|
|
for ( i = 0; (node = srcElements[i]) != null; i++ ) {
|
|
|
|
cloneCopyEvent( node, destElements[i] );
|
2011-01-20 19:25:56 +00:00
|
|
|
}
|
2012-11-19 14:50:19 +00:00
|
|
|
} else {
|
|
|
|
cloneCopyEvent( elem, clone );
|
2011-01-20 19:25:56 +00:00
|
|
|
}
|
|
|
|
}
|
2011-02-23 18:18:44 +00:00
|
|
|
|
2012-11-19 14:50:19 +00:00
|
|
|
// Preserve script evaluation history
|
|
|
|
destElements = getAll( clone, "script" );
|
|
|
|
if ( destElements.length > 0 ) {
|
|
|
|
setGlobalEval( destElements, !inPage && getAll( elem, "script" ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
destElements = srcElements = node = null;
|
2011-05-25 19:18:13 +00:00
|
|
|
|
2011-01-20 19:25:56 +00:00
|
|
|
// Return the cloned set
|
|
|
|
return clone;
|
2011-04-02 01:13:01 +00:00
|
|
|
},
|
|
|
|
|
2013-01-08 03:25:26 +00:00
|
|
|
buildFragment: function( elems, context, scripts, selection ) {
|
2013-01-29 00:04:58 +00:00
|
|
|
var j, elem, contains,
|
|
|
|
tmp, tag, tbody, wrap,
|
2013-01-09 09:23:34 +00:00
|
|
|
l = elems.length,
|
2011-04-12 22:30:21 +00:00
|
|
|
|
2013-01-09 09:52:15 +00:00
|
|
|
// Ensure a safe fragment
|
|
|
|
safe = createSafeFragment( context ),
|
|
|
|
|
|
|
|
nodes = [],
|
|
|
|
i = 0;
|
2009-03-18 21:15:38 +00:00
|
|
|
|
2013-01-09 09:23:34 +00:00
|
|
|
for ( ; i < l; i++ ) {
|
|
|
|
elem = elems[ i ];
|
2013-01-09 09:52:15 +00:00
|
|
|
|
2012-11-19 14:50:19 +00:00
|
|
|
if ( elem || elem === 0 ) {
|
2013-01-09 09:52:15 +00:00
|
|
|
|
2012-11-19 14:50:19 +00:00
|
|
|
// Add nodes directly
|
2012-11-19 22:17:48 +00:00
|
|
|
if ( jQuery.type( elem ) === "object" ) {
|
2013-01-09 09:23:34 +00:00
|
|
|
jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem );
|
2009-03-18 21:15:38 +00:00
|
|
|
|
2012-11-19 14:50:19 +00:00
|
|
|
// Convert non-html into a text node
|
|
|
|
} else if ( !rhtml.test( elem ) ) {
|
2013-01-09 09:23:34 +00:00
|
|
|
nodes.push( context.createTextNode( elem ) );
|
2009-03-18 21:15:38 +00:00
|
|
|
|
2012-11-19 14:50:19 +00:00
|
|
|
// Convert html into DOM nodes
|
2011-04-22 01:51:23 +00:00
|
|
|
} else {
|
2012-11-19 14:50:19 +00:00
|
|
|
tmp = tmp || safe.appendChild( context.createElement("div") );
|
2009-03-18 21:15:38 +00:00
|
|
|
|
2012-11-19 14:50:19 +00:00
|
|
|
// Deserialize a standard representation
|
2012-04-05 03:00:58 +00:00
|
|
|
tag = ( rtagName.exec( elem ) || ["", ""] )[1].toLowerCase();
|
|
|
|
wrap = wrapMap[ tag ] || wrapMap._default;
|
2013-01-13 17:45:52 +00:00
|
|
|
|
|
|
|
tmp.innerHTML = wrap[1] + elem.replace( rxhtmlTag, "<$1></$2>" ) + wrap[2];
|
2009-03-18 21:15:38 +00:00
|
|
|
|
2012-11-19 14:50:19 +00:00
|
|
|
// Descend through wrappers to the right content
|
|
|
|
j = wrap[0];
|
|
|
|
while ( j-- ) {
|
|
|
|
tmp = tmp.lastChild;
|
|
|
|
}
|
|
|
|
|
2013-09-09 16:22:37 +00:00
|
|
|
// Manually add leading whitespace removed by IE
|
|
|
|
if ( !support.leadingWhitespace && rleadingWhitespace.test( elem ) ) {
|
|
|
|
nodes.push( context.createTextNode( rleadingWhitespace.exec( elem )[0] ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Remove IE's autoinserted <tbody> from table fragments
|
|
|
|
if ( !support.tbody ) {
|
|
|
|
|
|
|
|
// String was a <table>, *may* have spurious <tbody>
|
|
|
|
elem = tag === "table" && !rtbody.test( elem ) ?
|
|
|
|
tmp.firstChild :
|
|
|
|
|
|
|
|
// String was a bare <thead> or <tfoot>
|
|
|
|
wrap[1] === "<table>" && !rtbody.test( elem ) ?
|
|
|
|
tmp :
|
|
|
|
0;
|
|
|
|
|
|
|
|
j = elem && elem.childNodes.length;
|
|
|
|
while ( j-- ) {
|
|
|
|
if ( jQuery.nodeName( (tbody = elem.childNodes[j]), "tbody" ) && !tbody.childNodes.length ) {
|
|
|
|
elem.removeChild( tbody );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
jQuery.merge( nodes, tmp.childNodes );
|
|
|
|
|
|
|
|
// Fix #12392 for WebKit and IE > 9
|
|
|
|
tmp.textContent = "";
|
|
|
|
|
|
|
|
// Fix #12392 for oldIE
|
|
|
|
while ( tmp.firstChild ) {
|
|
|
|
tmp.removeChild( tmp.firstChild );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Remember the top-level container for proper cleanup
|
|
|
|
tmp = safe.lastChild;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Fix #11356: Clear elements from fragment
|
|
|
|
if ( tmp ) {
|
|
|
|
safe.removeChild( tmp );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Reset defaultChecked for any radios and checkboxes
|
|
|
|
// about to be appended to the DOM in IE 6/7 (#8060)
|
|
|
|
if ( !support.appendChecked ) {
|
|
|
|
jQuery.grep( getAll( nodes, "input" ), fixDefaultChecked );
|
|
|
|
}
|
|
|
|
|
|
|
|
i = 0;
|
|
|
|
while ( (elem = nodes[ i++ ]) ) {
|
|
|
|
|
|
|
|
// #4087 - If origin and destination elements are the same, and this is
|
|
|
|
// that element, do not do anything
|
|
|
|
if ( selection && jQuery.inArray( elem, selection ) !== -1 ) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
contains = jQuery.contains( elem.ownerDocument, elem );
|
|
|
|
|
|
|
|
// Append to fragment
|
|
|
|
tmp = getAll( safe.appendChild( elem ), "script" );
|
|
|
|
|
|
|
|
// Preserve script evaluation history
|
|
|
|
if ( contains ) {
|
|
|
|
setGlobalEval( tmp );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Capture executables
|
|
|
|
if ( scripts ) {
|
|
|
|
j = 0;
|
|
|
|
while ( (elem = tmp[ j++ ]) ) {
|
|
|
|
if ( rscriptType.test( elem.type || "" ) ) {
|
|
|
|
scripts.push( elem );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
tmp = null;
|
|
|
|
|
|
|
|
return safe;
|
|
|
|
},
|
|
|
|
|
|
|
|
cleanData: function( elems, /* internal */ acceptData ) {
|
|
|
|
var elem, type, id, data,
|
|
|
|
i = 0,
|
|
|
|
internalKey = jQuery.expando,
|
|
|
|
cache = jQuery.cache,
|
|
|
|
deleteExpando = support.deleteExpando,
|
|
|
|
special = jQuery.event.special;
|
|
|
|
|
|
|
|
for ( ; (elem = elems[i]) != null; i++ ) {
|
|
|
|
if ( acceptData || jQuery.acceptData( elem ) ) {
|
|
|
|
|
|
|
|
id = elem[ internalKey ];
|
|
|
|
data = id && cache[ id ];
|
|
|
|
|
|
|
|
if ( data ) {
|
|
|
|
if ( data.events ) {
|
|
|
|
for ( type in data.events ) {
|
|
|
|
if ( special[ type ] ) {
|
|
|
|
jQuery.event.remove( elem, type );
|
|
|
|
|
|
|
|
// This is a shortcut to avoid jQuery.event.remove's overhead
|
|
|
|
} else {
|
|
|
|
jQuery.removeEvent( elem, type, data.handle );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Remove cache only if it was not already removed by jQuery.event.remove
|
|
|
|
if ( cache[ id ] ) {
|
|
|
|
|
|
|
|
delete cache[ id ];
|
|
|
|
|
|
|
|
// IE does not allow us to delete expando properties from nodes,
|
|
|
|
// nor does it have a removeAttribute function on Document nodes;
|
|
|
|
// we must handle all of these cases
|
|
|
|
if ( deleteExpando ) {
|
|
|
|
delete elem[ internalKey ];
|
|
|
|
|
|
|
|
} else if ( typeof elem.removeAttribute !== strundefined ) {
|
|
|
|
elem.removeAttribute( internalKey );
|
|
|
|
|
|
|
|
} else {
|
|
|
|
elem[ internalKey ] = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
deletedIds.push( id );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
jQuery.fn.extend({
|
|
|
|
text: function( value ) {
|
|
|
|
return access( this, function( value ) {
|
|
|
|
return value === undefined ?
|
|
|
|
jQuery.text( this ) :
|
|
|
|
this.empty().append( ( this[0] && this[0].ownerDocument || document ).createTextNode( value ) );
|
|
|
|
}, null, value, arguments.length );
|
|
|
|
},
|
|
|
|
|
|
|
|
append: function() {
|
|
|
|
return this.domManip( arguments, function( elem ) {
|
|
|
|
if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
|
|
|
|
var target = manipulationTarget( this, elem );
|
|
|
|
target.appendChild( elem );
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
prepend: function() {
|
|
|
|
return this.domManip( arguments, function( elem ) {
|
|
|
|
if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
|
|
|
|
var target = manipulationTarget( this, elem );
|
|
|
|
target.insertBefore( elem, target.firstChild );
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
before: function() {
|
|
|
|
return this.domManip( arguments, function( elem ) {
|
|
|
|
if ( this.parentNode ) {
|
|
|
|
this.parentNode.insertBefore( elem, this );
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
after: function() {
|
|
|
|
return this.domManip( arguments, function( elem ) {
|
|
|
|
if ( this.parentNode ) {
|
|
|
|
this.parentNode.insertBefore( elem, this.nextSibling );
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
remove: function( selector, keepData /* Internal Use Only */ ) {
|
|
|
|
var elem,
|
|
|
|
elems = selector ? jQuery.filter( selector, this ) : this,
|
|
|
|
i = 0;
|
|
|
|
|
|
|
|
for ( ; (elem = elems[i]) != null; i++ ) {
|
|
|
|
|
|
|
|
if ( !keepData && elem.nodeType === 1 ) {
|
|
|
|
jQuery.cleanData( getAll( elem ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( elem.parentNode ) {
|
|
|
|
if ( keepData && jQuery.contains( elem.ownerDocument, elem ) ) {
|
|
|
|
setGlobalEval( getAll( elem, "script" ) );
|
|
|
|
}
|
|
|
|
elem.parentNode.removeChild( elem );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
|
|
|
empty: function() {
|
|
|
|
var elem,
|
|
|
|
i = 0;
|
|
|
|
|
|
|
|
for ( ; (elem = this[i]) != null; i++ ) {
|
|
|
|
// Remove element nodes and prevent memory leaks
|
|
|
|
if ( elem.nodeType === 1 ) {
|
|
|
|
jQuery.cleanData( getAll( elem, false ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Remove any remaining nodes
|
|
|
|
while ( elem.firstChild ) {
|
|
|
|
elem.removeChild( elem.firstChild );
|
|
|
|
}
|
|
|
|
|
|
|
|
// If this is a select, ensure that it displays empty (#12336)
|
|
|
|
// Support: IE<9
|
|
|
|
if ( elem.options && jQuery.nodeName( elem, "select" ) ) {
|
|
|
|
elem.options.length = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return this;
|
|
|
|
},
|
2009-03-18 21:15:38 +00:00
|
|
|
|
2013-09-09 16:22:37 +00:00
|
|
|
clone: function( dataAndEvents, deepDataAndEvents ) {
|
|
|
|
dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
|
|
|
|
deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
|
2009-03-18 21:15:38 +00:00
|
|
|
|
2013-09-09 16:22:37 +00:00
|
|
|
return this.map( function () {
|
|
|
|
return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
|
|
|
|
});
|
|
|
|
},
|
2012-11-19 14:50:19 +00:00
|
|
|
|
2013-09-09 16:22:37 +00:00
|
|
|
html: function( value ) {
|
|
|
|
return access( this, function( value ) {
|
|
|
|
var elem = this[ 0 ] || {},
|
|
|
|
i = 0,
|
|
|
|
l = this.length;
|
2012-11-19 14:50:19 +00:00
|
|
|
|
2013-09-09 16:22:37 +00:00
|
|
|
if ( value === undefined ) {
|
|
|
|
return elem.nodeType === 1 ?
|
|
|
|
elem.innerHTML.replace( rinlinejQuery, "" ) :
|
|
|
|
undefined;
|
|
|
|
}
|
2009-03-18 21:15:38 +00:00
|
|
|
|
2013-09-09 16:22:37 +00:00
|
|
|
// See if we can take a shortcut and just use innerHTML
|
|
|
|
if ( typeof value === "string" && !rnoInnerhtml.test( value ) &&
|
|
|
|
( support.htmlSerialize || !rnoshimcache.test( value ) ) &&
|
|
|
|
( support.leadingWhitespace || !rleadingWhitespace.test( value ) ) &&
|
|
|
|
!wrapMap[ ( rtagName.exec( value ) || ["", ""] )[1].toLowerCase() ] ) {
|
2012-10-26 00:41:47 +00:00
|
|
|
|
2013-09-09 16:22:37 +00:00
|
|
|
value = value.replace( rxhtmlTag, "<$1></$2>" );
|
2012-10-26 00:41:47 +00:00
|
|
|
|
2013-09-09 16:22:37 +00:00
|
|
|
try {
|
|
|
|
for (; i < l; i++ ) {
|
|
|
|
// Remove element nodes and prevent memory leaks
|
|
|
|
elem = this[i] || {};
|
|
|
|
if ( elem.nodeType === 1 ) {
|
|
|
|
jQuery.cleanData( getAll( elem, false ) );
|
|
|
|
elem.innerHTML = value;
|
|
|
|
}
|
2012-10-26 00:41:47 +00:00
|
|
|
}
|
|
|
|
|
2013-09-09 16:22:37 +00:00
|
|
|
elem = 0;
|
|
|
|
|
|
|
|
// If using innerHTML throws an exception, use the fallback method
|
|
|
|
} catch(e) {}
|
2012-04-16 02:54:18 +00:00
|
|
|
}
|
2012-04-05 03:00:58 +00:00
|
|
|
|
2013-09-09 16:22:37 +00:00
|
|
|
if ( elem ) {
|
|
|
|
this.empty().append( value );
|
|
|
|
}
|
|
|
|
}, null, value, arguments.length );
|
|
|
|
},
|
2009-03-23 01:55:17 +00:00
|
|
|
|
2013-09-09 16:22:37 +00:00
|
|
|
replaceWith: function() {
|
|
|
|
var
|
|
|
|
// Snapshot the DOM in case .domManip sweeps something relevant into its fragment
|
|
|
|
args = jQuery.map( this, function( elem ) {
|
|
|
|
return [ elem.nextSibling, elem.parentNode ];
|
|
|
|
}),
|
|
|
|
i = 0;
|
2009-03-18 21:15:38 +00:00
|
|
|
|
2013-09-09 16:22:37 +00:00
|
|
|
// Make the changes, replacing each context element with the new content
|
|
|
|
this.domManip( arguments, function( elem ) {
|
|
|
|
var next = args[ i++ ],
|
|
|
|
parent = args[ i++ ];
|
2012-11-19 14:50:19 +00:00
|
|
|
|
2013-09-09 16:22:37 +00:00
|
|
|
if ( parent ) {
|
|
|
|
// Don't use the snapshot next if it has moved (#13810)
|
|
|
|
if ( next && next.parentNode !== parent ) {
|
|
|
|
next = this.nextSibling;
|
|
|
|
}
|
|
|
|
jQuery( this ).remove();
|
|
|
|
parent.insertBefore( elem, next );
|
2013-01-08 03:25:26 +00:00
|
|
|
}
|
2013-09-09 16:22:37 +00:00
|
|
|
// Allow new content to include elements from the context set
|
|
|
|
}, true );
|
2013-01-09 09:52:15 +00:00
|
|
|
|
2013-09-09 16:22:37 +00:00
|
|
|
// Force removal if there was no new content (e.g., from empty arguments)
|
|
|
|
return i ? this : this.remove();
|
|
|
|
},
|
2013-01-09 09:52:15 +00:00
|
|
|
|
2013-09-09 16:22:37 +00:00
|
|
|
detach: function( selector ) {
|
|
|
|
return this.remove( selector, true );
|
|
|
|
},
|
2012-11-19 14:50:19 +00:00
|
|
|
|
2013-09-09 16:22:37 +00:00
|
|
|
domManip: function( args, callback, allowIntersection ) {
|
2010-12-07 01:36:42 +00:00
|
|
|
|
2013-09-09 16:22:37 +00:00
|
|
|
// Flatten any nested arrays
|
|
|
|
args = concat.apply( [], args );
|
|
|
|
|
|
|
|
var first, node, hasScripts,
|
|
|
|
scripts, doc, fragment,
|
|
|
|
i = 0,
|
|
|
|
l = this.length,
|
|
|
|
set = this,
|
|
|
|
iNoClone = l - 1,
|
|
|
|
value = args[0],
|
|
|
|
isFunction = jQuery.isFunction( value );
|
|
|
|
|
|
|
|
// We can't cloneNode fragments that contain checked, in WebKit
|
|
|
|
if ( isFunction || !( l <= 1 || typeof value !== "string" || support.checkClone || !rchecked.test( value ) ) ) {
|
|
|
|
return this.each(function( index ) {
|
|
|
|
var self = set.eq( index );
|
|
|
|
if ( isFunction ) {
|
|
|
|
args[0] = value.call( this, index, self.html() );
|
2009-03-18 21:15:38 +00:00
|
|
|
}
|
2013-09-09 16:22:37 +00:00
|
|
|
self.domManip( args, callback, allowIntersection );
|
|
|
|
});
|
2009-03-18 21:15:38 +00:00
|
|
|
}
|
|
|
|
|
2013-09-09 16:22:37 +00:00
|
|
|
if ( l ) {
|
|
|
|
fragment = jQuery.buildFragment( args, this[ 0 ].ownerDocument, false, !allowIntersection && this );
|
|
|
|
first = fragment.firstChild;
|
2010-12-07 01:36:42 +00:00
|
|
|
|
2013-09-09 16:22:37 +00:00
|
|
|
if ( fragment.childNodes.length === 1 ) {
|
|
|
|
fragment = first;
|
|
|
|
}
|
2010-12-07 01:36:42 +00:00
|
|
|
|
2013-09-09 16:22:37 +00:00
|
|
|
if ( first ) {
|
|
|
|
scripts = jQuery.map( getAll( fragment, "script" ), disableScript );
|
|
|
|
hasScripts = scripts.length;
|
2010-12-07 01:36:42 +00:00
|
|
|
|
2013-09-09 16:22:37 +00:00
|
|
|
// Use the original fragment for the last item instead of the first because it can end up
|
|
|
|
// being emptied incorrectly in certain situations (#8070).
|
|
|
|
for ( ; i < l; i++ ) {
|
|
|
|
node = fragment;
|
2010-12-07 01:36:42 +00:00
|
|
|
|
2013-09-09 16:22:37 +00:00
|
|
|
if ( i !== iNoClone ) {
|
|
|
|
node = jQuery.clone( node, true, true );
|
2010-02-13 11:10:43 +00:00
|
|
|
|
2013-09-09 16:22:37 +00:00
|
|
|
// Keep references to cloned scripts for later restoration
|
|
|
|
if ( hasScripts ) {
|
|
|
|
jQuery.merge( scripts, getAll( node, "script" ) );
|
2010-02-13 11:10:43 +00:00
|
|
|
}
|
2010-01-28 20:25:52 +00:00
|
|
|
}
|
2010-12-07 01:36:42 +00:00
|
|
|
|
2013-09-09 16:22:37 +00:00
|
|
|
callback.call( this[i], node, i );
|
|
|
|
}
|
2010-02-13 11:57:58 +00:00
|
|
|
|
2013-09-09 16:22:37 +00:00
|
|
|
if ( hasScripts ) {
|
|
|
|
doc = scripts[ scripts.length - 1 ].ownerDocument;
|
2012-07-06 13:22:44 +00:00
|
|
|
|
2013-09-09 16:22:37 +00:00
|
|
|
// Reenable scripts
|
|
|
|
jQuery.map( scripts, restoreScript );
|
2010-12-07 01:36:42 +00:00
|
|
|
|
2013-09-09 16:22:37 +00:00
|
|
|
// Evaluate executable scripts on first document insertion
|
|
|
|
for ( i = 0; i < hasScripts; i++ ) {
|
|
|
|
node = scripts[ i ];
|
|
|
|
if ( rscriptType.test( node.type || "" ) &&
|
|
|
|
!jQuery._data( node, "globalEval" ) && jQuery.contains( doc, node ) ) {
|
2012-07-06 13:22:44 +00:00
|
|
|
|
2013-09-09 16:22:37 +00:00
|
|
|
if ( node.src ) {
|
|
|
|
// Optional AJAX dependency, but won't run scripts if not present
|
|
|
|
if ( jQuery._evalUrl ) {
|
|
|
|
jQuery._evalUrl( node.src );
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
jQuery.globalEval( ( node.text || node.textContent || node.innerHTML || "" ).replace( rcleanScript, "" ) );
|
|
|
|
}
|
2012-07-06 13:22:44 +00:00
|
|
|
}
|
|
|
|
}
|
2012-04-05 01:17:01 +00:00
|
|
|
}
|
2013-09-09 16:22:37 +00:00
|
|
|
|
|
|
|
// Fix #11809: Avoid leaking memory
|
|
|
|
fragment = first = null;
|
2010-01-28 20:25:52 +00:00
|
|
|
}
|
2009-03-18 21:15:38 +00:00
|
|
|
}
|
2013-09-09 16:22:37 +00:00
|
|
|
|
|
|
|
return this;
|
2009-03-18 21:15:38 +00:00
|
|
|
}
|
2010-01-25 02:37:05 +00:00
|
|
|
});
|
2013-08-15 18:15:49 +00:00
|
|
|
|
2013-09-09 16:22:37 +00:00
|
|
|
jQuery.each({
|
|
|
|
appendTo: "append",
|
|
|
|
prependTo: "prepend",
|
|
|
|
insertBefore: "before",
|
|
|
|
insertAfter: "after",
|
|
|
|
replaceAll: "replaceWith"
|
|
|
|
}, function( name, original ) {
|
|
|
|
jQuery.fn[ name ] = function( selector ) {
|
|
|
|
var elems,
|
|
|
|
i = 0,
|
|
|
|
ret = [],
|
|
|
|
insert = jQuery( selector ),
|
|
|
|
last = insert.length - 1;
|
|
|
|
|
|
|
|
for ( ; i <= last; i++ ) {
|
|
|
|
elems = i === last ? this : this.clone(true);
|
|
|
|
jQuery( insert[i] )[ original ]( elems );
|
|
|
|
|
|
|
|
// Modern browsers can apply jQuery collections as arrays, but oldIE needs a .get()
|
|
|
|
push.apply( ret, elems.get() );
|
|
|
|
}
|
|
|
|
|
|
|
|
return this.pushStack( ret );
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
2013-09-09 01:25:27 +00:00
|
|
|
return jQuery;
|
2013-08-15 18:15:49 +00:00
|
|
|
});
|