2009-07-19 17:48:30 +02:00
|
|
|
var rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g,
|
|
|
|
rleadingWhitespace = /^\s+/,
|
2009-10-12 18:26:01 +02:00
|
|
|
rxhtmlTag = /(<([\w:]+)[^>]*?)\/>/g,
|
2009-07-19 17:48:30 +02:00
|
|
|
rselfClosing = /^(?:abbr|br|col|img|input|link|meta|param|hr|area|embed)$/i,
|
2009-10-12 18:26:01 +02:00
|
|
|
rtagName = /<([\w:]+)/,
|
2009-07-19 17:57:43 +02:00
|
|
|
rtbody = /<tbody/i,
|
2009-11-11 20:23:56 +01:00
|
|
|
rhtml = /<|&\w+;/,
|
2009-07-19 17:57:43 +02:00
|
|
|
fcloseTag = function(all, front, tag){
|
|
|
|
return rselfClosing.test(tag) ?
|
|
|
|
all :
|
|
|
|
front + "></" + tag + ">";
|
2009-09-07 22:55:36 +02:00
|
|
|
},
|
|
|
|
wrapMap = {
|
|
|
|
option: [ 1, "<select multiple='multiple'>", "</select>" ],
|
|
|
|
legend: [ 1, "<fieldset>", "</fieldset>" ],
|
|
|
|
thead: [ 1, "<table>", "</table>" ],
|
|
|
|
tr: [ 2, "<table><tbody>", "</tbody></table>" ],
|
|
|
|
td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
|
|
|
|
col: [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ],
|
2009-12-07 02:26:39 +01:00
|
|
|
area: [ 1, "<map>", "</map>" ],
|
2009-09-07 22:55:36 +02:00
|
|
|
_default: [ 0, "", "" ]
|
2009-07-19 18:21:08 +02:00
|
|
|
};
|
2009-07-19 17:48:30 +02:00
|
|
|
|
2009-09-07 22:55:36 +02:00
|
|
|
wrapMap.optgroup = wrapMap.option;
|
|
|
|
wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
|
|
|
|
wrapMap.th = wrapMap.td;
|
|
|
|
|
|
|
|
// IE can't serialize <link> and <script> tags normally
|
|
|
|
if ( !jQuery.support.htmlSerialize ) {
|
|
|
|
wrapMap._default = [ 1, "div<div>", "</div>" ];
|
|
|
|
}
|
|
|
|
|
2009-03-18 22:15:38 +01:00
|
|
|
jQuery.fn.extend({
|
|
|
|
text: function( text ) {
|
2009-12-10 06:15:49 +01:00
|
|
|
if(jQuery.isFunction(text)) {
|
|
|
|
return this.each(function() {
|
|
|
|
return jQuery(this).text( text.call(this) );
|
|
|
|
});
|
|
|
|
}
|
2009-12-10 05:57:19 +01:00
|
|
|
|
2009-11-17 20:52:08 +01:00
|
|
|
if ( typeof text !== "object" && text !== undefined ) {
|
2009-03-18 22:15:38 +01:00
|
|
|
return this.empty().append( (this[0] && this[0].ownerDocument || document).createTextNode( text ) );
|
2009-11-17 20:52:08 +01:00
|
|
|
}
|
2009-03-18 22:15:38 +01:00
|
|
|
|
2009-12-07 02:47:41 +01:00
|
|
|
return jQuery.getText( this );
|
2009-03-18 22:15:38 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
wrapAll: function( html ) {
|
2009-07-19 17:29:03 +02:00
|
|
|
if ( jQuery.isFunction( html ) ) {
|
|
|
|
return this.each(function() {
|
|
|
|
jQuery(this).wrapAll( html.apply(this, arguments) );
|
|
|
|
});
|
2009-07-12 23:08:54 +02:00
|
|
|
}
|
2009-07-21 11:17:33 +02:00
|
|
|
|
2009-03-18 22:15:38 +01:00
|
|
|
if ( this[0] ) {
|
|
|
|
// The elements to wrap the target around
|
2009-12-08 20:21:24 +01:00
|
|
|
var wrap = jQuery( html, this[0].ownerDocument ).eq(0).clone(true);
|
2009-03-18 22:15:38 +01:00
|
|
|
|
2009-07-19 17:29:03 +02:00
|
|
|
if ( this[0].parentNode ) {
|
2009-03-18 22:15:38 +01:00
|
|
|
wrap.insertBefore( this[0] );
|
2009-07-19 17:29:03 +02:00
|
|
|
}
|
2009-03-18 22:15:38 +01:00
|
|
|
|
|
|
|
wrap.map(function(){
|
|
|
|
var elem = this;
|
|
|
|
|
2009-07-19 17:29:03 +02:00
|
|
|
while ( elem.firstChild && elem.firstChild.nodeType === 1 ) {
|
2009-03-18 22:15:38 +01:00
|
|
|
elem = elem.firstChild;
|
2009-07-19 17:29:03 +02:00
|
|
|
}
|
2009-03-18 22:15:38 +01:00
|
|
|
|
|
|
|
return elem;
|
|
|
|
}).append(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
|
|
|
wrapInner: function( html ) {
|
|
|
|
return this.each(function(){
|
|
|
|
jQuery( this ).contents().wrapAll( html );
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
wrap: function( html ) {
|
|
|
|
return this.each(function(){
|
|
|
|
jQuery( this ).wrapAll( html );
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2009-09-25 23:41:21 +02:00
|
|
|
unwrap: function() {
|
|
|
|
return this.parent().each(function(){
|
|
|
|
if ( !jQuery.nodeName( this, "body" ) ) {
|
|
|
|
jQuery( this ).replaceWith( this.childNodes );
|
|
|
|
}
|
|
|
|
}).end();
|
|
|
|
},
|
2009-12-10 05:57:19 +01:00
|
|
|
|
2009-03-18 22:15:38 +01:00
|
|
|
append: function() {
|
|
|
|
return this.domManip(arguments, true, function(elem){
|
2009-07-19 17:29:03 +02:00
|
|
|
if ( this.nodeType === 1 ) {
|
2009-03-18 22:15:38 +01:00
|
|
|
this.appendChild( elem );
|
2009-07-19 17:29:03 +02:00
|
|
|
}
|
2009-03-18 22:15:38 +01:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
prepend: function() {
|
|
|
|
return this.domManip(arguments, true, function(elem){
|
2009-07-19 17:29:03 +02:00
|
|
|
if ( this.nodeType === 1 ) {
|
2009-03-18 22:15:38 +01:00
|
|
|
this.insertBefore( elem, this.firstChild );
|
2009-07-19 17:29:03 +02:00
|
|
|
}
|
2009-03-18 22:15:38 +01:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
before: function() {
|
2009-09-15 00:09:42 +02:00
|
|
|
if ( this[0] && this[0].parentNode ) {
|
|
|
|
return this.domManip(arguments, false, function(elem){
|
|
|
|
this.parentNode.insertBefore( elem, this );
|
|
|
|
});
|
A follow-up to [6578] (which stopped adding expandos to elements that didn't have data). That broke jQuery.unique() (so we're now using the unique from Sizzle). Using Sizzle's unique (which also sorts in document order) changed how add, andSelf, parents, nextAll, prevAll, and siblings work. after and before were changed to not use .add() (in order to guarantee their position in the jQuery set). Also, jQuery.data(elem) was updated to return that element's data object (instead of its ID).
$("<div/>").after("<span/>")
=> [ div, span ]
(calling after on a disconnected DOM node adds the nodes to the end of the jQuery set)
$("<div/>").before("<span/>")
=> [ span, div ]
(calling before on a disconnected DOM node adds the nodes to the beginning of the jQuery set)
$("div").add("span")
=> [ div, span, span, div, span ]
(results now come out in document order)
$("div").find("code").andSelf();
=> [ div, code, code ]
(results now come out in document order)
Same goes for .parents(), .nextAll(), .prevAll(), and .siblings().
Exception: .parents() will still return the results in reverse document order.
jQuery.data(elem)
=> { object of data }
(no longer returns the unique ID assigned to the node)
2009-09-25 19:55:20 +02:00
|
|
|
} else if ( arguments.length ) {
|
|
|
|
var set = jQuery(arguments[0]);
|
|
|
|
set.push.apply( set, this.toArray() );
|
|
|
|
return this.pushStack( set, "before", arguments );
|
2009-09-15 00:09:42 +02:00
|
|
|
}
|
2009-03-18 22:15:38 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
after: function() {
|
2009-09-15 00:09:42 +02:00
|
|
|
if ( this[0] && this[0].parentNode ) {
|
|
|
|
return this.domManip(arguments, false, function(elem){
|
|
|
|
this.parentNode.insertBefore( elem, this.nextSibling );
|
|
|
|
});
|
A follow-up to [6578] (which stopped adding expandos to elements that didn't have data). That broke jQuery.unique() (so we're now using the unique from Sizzle). Using Sizzle's unique (which also sorts in document order) changed how add, andSelf, parents, nextAll, prevAll, and siblings work. after and before were changed to not use .add() (in order to guarantee their position in the jQuery set). Also, jQuery.data(elem) was updated to return that element's data object (instead of its ID).
$("<div/>").after("<span/>")
=> [ div, span ]
(calling after on a disconnected DOM node adds the nodes to the end of the jQuery set)
$("<div/>").before("<span/>")
=> [ span, div ]
(calling before on a disconnected DOM node adds the nodes to the beginning of the jQuery set)
$("div").add("span")
=> [ div, span, span, div, span ]
(results now come out in document order)
$("div").find("code").andSelf();
=> [ div, code, code ]
(results now come out in document order)
Same goes for .parents(), .nextAll(), .prevAll(), and .siblings().
Exception: .parents() will still return the results in reverse document order.
jQuery.data(elem)
=> { object of data }
(no longer returns the unique ID assigned to the node)
2009-09-25 19:55:20 +02:00
|
|
|
} else if ( arguments.length ) {
|
|
|
|
var set = this.pushStack( this, "after", arguments );
|
|
|
|
set.push.apply( set, jQuery(arguments[0]).toArray() );
|
|
|
|
return set;
|
2009-09-15 00:09:42 +02:00
|
|
|
}
|
2009-03-18 22:15:38 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
clone: function( events ) {
|
|
|
|
// Do the clone
|
|
|
|
var ret = this.map(function(){
|
|
|
|
if ( !jQuery.support.noCloneEvent && !jQuery.isXMLDoc(this) ) {
|
|
|
|
// IE copies events bound via attachEvent when
|
|
|
|
// using cloneNode. Calling detachEvent on the
|
|
|
|
// clone will also remove the events from the orignal
|
|
|
|
// In order to get around this, we use innerHTML.
|
|
|
|
// Unfortunately, this means some modifications to
|
|
|
|
// attributes in IE that are actually only stored
|
|
|
|
// as properties will not be copied (such as the
|
|
|
|
// the name attribute on an input).
|
|
|
|
var html = this.outerHTML, ownerDocument = this.ownerDocument;
|
|
|
|
if ( !html ) {
|
|
|
|
var div = ownerDocument.createElement("div");
|
|
|
|
div.appendChild( this.cloneNode(true) );
|
|
|
|
html = div.innerHTML;
|
|
|
|
}
|
|
|
|
|
2009-07-19 17:48:30 +02:00
|
|
|
return jQuery.clean([html.replace(rinlinejQuery, "")
|
|
|
|
.replace(rleadingWhitespace, "")], ownerDocument)[0];
|
|
|
|
} else {
|
2009-03-18 22:15:38 +01:00
|
|
|
return this.cloneNode(true);
|
2009-07-19 17:48:30 +02:00
|
|
|
}
|
2009-03-18 22:15:38 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
// Copy the events from the original to the clone
|
|
|
|
if ( events === true ) {
|
2009-12-02 23:15:09 +01:00
|
|
|
cloneCopyEvent( this, ret );
|
|
|
|
cloneCopyEvent( this.find("*"), ret.find("*") );
|
2009-03-18 22:15:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Return the cloned set
|
|
|
|
return ret;
|
|
|
|
},
|
|
|
|
|
|
|
|
html: function( value ) {
|
2009-09-07 22:55:36 +02:00
|
|
|
if ( value === undefined ) {
|
|
|
|
return this[0] ?
|
2009-07-19 17:48:30 +02:00
|
|
|
this[0].innerHTML.replace(rinlinejQuery, "") :
|
2009-09-07 22:55:36 +02:00
|
|
|
null;
|
|
|
|
|
|
|
|
// See if we can take a shortcut and just use innerHTML
|
|
|
|
} else if ( typeof value === "string" && !/<script/i.test( value ) &&
|
2009-12-02 21:20:33 +01:00
|
|
|
(jQuery.support.leadingWhitespace || !rleadingWhitespace.test( value )) &&
|
2009-09-07 22:55:36 +02:00
|
|
|
!wrapMap[ (rtagName.exec( value ) || ["", ""])[1].toLowerCase() ] ) {
|
|
|
|
|
2009-09-15 18:46:15 +02:00
|
|
|
try {
|
|
|
|
for ( var i = 0, l = this.length; i < l; i++ ) {
|
|
|
|
// Remove element nodes and prevent memory leaks
|
|
|
|
if ( this[i].nodeType === 1 ) {
|
|
|
|
cleanData( this[i].getElementsByTagName("*") );
|
|
|
|
this[i].innerHTML = value;
|
|
|
|
}
|
2009-09-07 22:55:36 +02:00
|
|
|
}
|
2009-09-15 18:46:15 +02:00
|
|
|
|
|
|
|
// If using innerHTML throws an exception, use the fallback method
|
|
|
|
} catch(e) {
|
|
|
|
this.empty().append( value );
|
2009-09-07 22:55:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
2009-03-18 22:15:38 +01:00
|
|
|
this.empty().append( value );
|
2009-09-07 22:55:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return this;
|
2009-03-18 22:15:38 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
replaceWith: function( value ) {
|
2009-09-15 00:09:42 +02:00
|
|
|
if ( this[0] && this[0].parentNode ) {
|
2009-12-05 21:30:36 +01:00
|
|
|
return this.each(function(){
|
|
|
|
var next = this.nextSibling, parent = this.parentNode;
|
|
|
|
|
|
|
|
jQuery(this).remove();
|
|
|
|
|
|
|
|
if ( next ) {
|
|
|
|
jQuery(next).before( value );
|
|
|
|
} else {
|
|
|
|
jQuery(parent).append( value );
|
|
|
|
}
|
|
|
|
});
|
2009-09-15 00:09:42 +02:00
|
|
|
} else {
|
|
|
|
return this.pushStack( jQuery(jQuery.isFunction(value) ? value() : value), "replaceWith", value );
|
|
|
|
}
|
2009-03-18 22:15:38 +01:00
|
|
|
},
|
|
|
|
|
2009-07-21 17:57:51 +02:00
|
|
|
detach: function( selector ) {
|
|
|
|
return this.remove( selector, true );
|
|
|
|
},
|
|
|
|
|
2009-03-18 22:15:38 +01:00
|
|
|
domManip: function( args, table, callback ) {
|
2009-09-07 20:58:01 +02:00
|
|
|
var results, first, value = args[0], scripts = [];
|
2009-07-12 22:19:43 +02:00
|
|
|
|
|
|
|
if ( jQuery.isFunction(value) ) {
|
|
|
|
return this.each(function() {
|
|
|
|
args[0] = value.call(this);
|
|
|
|
return jQuery(this).domManip( args, table, callback );
|
|
|
|
});
|
2009-07-19 17:48:30 +02:00
|
|
|
}
|
2009-07-11 15:49:46 +02:00
|
|
|
|
2009-03-18 22:15:38 +01:00
|
|
|
if ( this[0] ) {
|
2009-09-07 20:58:01 +02:00
|
|
|
// If we're in a fragment, just use that instead of building a new one
|
|
|
|
if ( args[0] && args[0].parentNode && args[0].parentNode.nodeType === 11 ) {
|
|
|
|
results = { fragment: args[0].parentNode };
|
|
|
|
} else {
|
2009-09-15 01:12:06 +02:00
|
|
|
results = buildFragment( args, this, scripts );
|
2009-07-11 15:49:46 +02:00
|
|
|
}
|
|
|
|
|
2009-09-07 20:58:01 +02:00
|
|
|
first = results.fragment.firstChild;
|
2009-03-18 22:15:38 +01:00
|
|
|
|
2009-07-11 15:49:46 +02:00
|
|
|
if ( first ) {
|
|
|
|
table = table && jQuery.nodeName( first, "tr" );
|
2009-03-23 02:55:17 +01:00
|
|
|
|
2009-07-11 15:49:46 +02:00
|
|
|
for ( var i = 0, l = this.length; i < l; i++ ) {
|
|
|
|
callback.call(
|
|
|
|
table ?
|
|
|
|
root(this[i], first) :
|
|
|
|
this[i],
|
2009-09-07 20:58:01 +02:00
|
|
|
results.cacheable || this.length > 1 || i > 0 ?
|
|
|
|
results.fragment.cloneNode(true) :
|
|
|
|
results.fragment
|
2009-07-11 15:49:46 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( scripts ) {
|
2009-03-18 22:15:38 +01:00
|
|
|
jQuery.each( scripts, evalScript );
|
2009-07-11 15:49:46 +02:00
|
|
|
}
|
2009-03-18 22:15:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return this;
|
2009-03-23 02:55:17 +01:00
|
|
|
|
2009-03-18 22:15:38 +01:00
|
|
|
function root( elem, cur ) {
|
2009-07-11 15:49:46 +02:00
|
|
|
return jQuery.nodeName(elem, "table") ?
|
2009-03-18 22:15:38 +01:00
|
|
|
(elem.getElementsByTagName("tbody")[0] ||
|
|
|
|
elem.appendChild(elem.ownerDocument.createElement("tbody"))) :
|
|
|
|
elem;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2009-12-02 23:15:09 +01:00
|
|
|
function cloneCopyEvent(orig, ret) {
|
|
|
|
var i = 0;
|
|
|
|
|
|
|
|
ret.each(function(){
|
2009-12-17 19:15:12 +01:00
|
|
|
if ( this.nodeName !== (orig[i] && orig[i].nodeName) ) {
|
2009-12-02 23:15:09 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-12-09 22:28:58 +01:00
|
|
|
jQuery.data( this, jQuery.data( orig[i++] ) );
|
2009-12-02 23:15:09 +01:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2009-09-07 20:58:01 +02:00
|
|
|
function buildFragment(args, nodes, scripts){
|
|
|
|
var fragment, cacheable, cached, cacheresults, doc;
|
|
|
|
|
|
|
|
if ( args.length === 1 && typeof args[0] === "string" && args[0].length < 512 && args[0].indexOf("<option") < 0 ) {
|
|
|
|
cacheable = true;
|
|
|
|
cacheresults = jQuery.fragments[ args[0] ];
|
|
|
|
if ( cacheresults ) {
|
|
|
|
if ( cacheresults !== 1 ) {
|
|
|
|
fragment = cacheresults;
|
|
|
|
}
|
|
|
|
cached = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( !fragment ) {
|
|
|
|
doc = (nodes && nodes[0] ? nodes[0].ownerDocument || nodes[0] : document);
|
|
|
|
fragment = doc.createDocumentFragment();
|
|
|
|
jQuery.clean( args, doc, fragment, scripts );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( cacheable ) {
|
|
|
|
jQuery.fragments[ args[0] ] = cacheresults ? fragment : 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return { fragment: fragment, cacheable: cacheable };
|
|
|
|
}
|
|
|
|
|
2009-07-11 15:49:46 +02:00
|
|
|
jQuery.fragments = {};
|
|
|
|
|
2009-03-18 22:15:38 +01:00
|
|
|
jQuery.each({
|
|
|
|
appendTo: "append",
|
|
|
|
prependTo: "prepend",
|
|
|
|
insertBefore: "before",
|
|
|
|
insertAfter: "after",
|
|
|
|
replaceAll: "replaceWith"
|
|
|
|
}, function(name, original){
|
|
|
|
jQuery.fn[ name ] = function( selector ) {
|
|
|
|
var ret = [], insert = jQuery( selector );
|
|
|
|
|
|
|
|
for ( var i = 0, l = insert.length; i < l; i++ ) {
|
|
|
|
var elems = (i > 0 ? this.clone(true) : this).get();
|
|
|
|
jQuery.fn[ original ].apply( jQuery(insert[i]), elems );
|
|
|
|
ret = ret.concat( elems );
|
|
|
|
}
|
2009-09-14 20:03:18 +02:00
|
|
|
return this.pushStack( ret, name, insert.selector );
|
2009-03-18 22:15:38 +01:00
|
|
|
};
|
|
|
|
});
|
|
|
|
|
|
|
|
jQuery.each({
|
2009-07-21 11:17:33 +02:00
|
|
|
// keepData is for internal use only--do not document
|
|
|
|
remove: function( selector, keepData ) {
|
2009-10-26 23:07:57 +01:00
|
|
|
if ( !selector || jQuery.filter( selector, [ this ] ).length ) {
|
2009-07-21 11:17:33 +02:00
|
|
|
if ( !keepData && this.nodeType === 1 ) {
|
2009-09-07 22:55:36 +02:00
|
|
|
cleanData( this.getElementsByTagName("*") );
|
|
|
|
cleanData( [ this ] );
|
2009-03-18 22:15:38 +01:00
|
|
|
}
|
|
|
|
|
2009-07-21 17:57:51 +02:00
|
|
|
if ( this.parentNode ) {
|
|
|
|
this.parentNode.removeChild( this );
|
|
|
|
}
|
2009-03-18 22:15:38 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
empty: function() {
|
|
|
|
// Remove element nodes and prevent memory leaks
|
|
|
|
if ( this.nodeType === 1 ) {
|
2009-09-07 22:55:36 +02:00
|
|
|
cleanData( this.getElementsByTagName("*") );
|
2009-03-18 22:15:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Remove any remaining nodes
|
|
|
|
while ( this.firstChild ) {
|
|
|
|
this.removeChild( this.firstChild );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, function(name, fn){
|
|
|
|
jQuery.fn[ name ] = function(){
|
|
|
|
return this.each( fn, arguments );
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
|
|
|
jQuery.extend({
|
2009-09-07 20:58:01 +02:00
|
|
|
clean: function( elems, context, fragment, scripts ) {
|
2009-03-18 22:15:38 +01:00
|
|
|
context = context || document;
|
|
|
|
|
|
|
|
// !context.createElement fails in IE with an error but returns typeof 'object'
|
2009-07-19 17:29:03 +02:00
|
|
|
if ( typeof context.createElement === "undefined" ) {
|
2009-03-18 22:15:38 +01:00
|
|
|
context = context.ownerDocument || context[0] && context[0].ownerDocument || document;
|
2009-07-19 17:29:03 +02:00
|
|
|
}
|
2009-03-18 22:15:38 +01:00
|
|
|
|
2009-12-06 02:06:00 +01:00
|
|
|
var ret = [];
|
2009-03-18 22:15:38 +01:00
|
|
|
|
|
|
|
jQuery.each(elems, function(i, elem){
|
2009-07-19 17:29:03 +02:00
|
|
|
if ( typeof elem === "number" ) {
|
2009-03-18 22:15:38 +01:00
|
|
|
elem += '';
|
2009-07-19 17:29:03 +02:00
|
|
|
}
|
2009-03-18 22:15:38 +01:00
|
|
|
|
2009-07-19 17:29:03 +02:00
|
|
|
if ( !elem ) { return; }
|
2009-03-18 22:15:38 +01:00
|
|
|
|
|
|
|
// Convert html string into DOM nodes
|
2009-09-15 01:12:06 +02:00
|
|
|
if ( typeof elem === "string" && !rhtml.test( elem ) ) {
|
|
|
|
elem = context.createTextNode( elem );
|
|
|
|
|
|
|
|
} else if ( typeof elem === "string" ) {
|
2009-03-18 22:15:38 +01:00
|
|
|
// Fix "XHTML"-style tags in all browsers
|
2009-07-19 17:57:43 +02:00
|
|
|
elem = elem.replace(rxhtmlTag, fcloseTag);
|
2009-03-18 22:15:38 +01:00
|
|
|
|
|
|
|
// Trim whitespace, otherwise indexOf won't work as expected
|
2009-09-07 22:55:36 +02:00
|
|
|
var tag = (rtagName.exec( elem ) || ["", ""])[1].toLowerCase(),
|
|
|
|
wrap = wrapMap[ tag ] || wrapMap._default,
|
2009-12-06 02:06:00 +01:00
|
|
|
depth = wrap[0],
|
|
|
|
div = context.createElement("div");
|
2009-03-18 22:15:38 +01:00
|
|
|
|
|
|
|
// Go to html and back, then peel off extra wrappers
|
|
|
|
div.innerHTML = wrap[1] + elem + wrap[2];
|
|
|
|
|
|
|
|
// Move to the right depth
|
2009-09-07 22:55:36 +02:00
|
|
|
while ( depth-- ) {
|
2009-03-18 22:15:38 +01:00
|
|
|
div = div.lastChild;
|
2009-07-19 17:29:03 +02:00
|
|
|
}
|
2009-03-18 22:15:38 +01:00
|
|
|
|
|
|
|
// Remove IE's autoinserted <tbody> from table fragments
|
|
|
|
if ( !jQuery.support.tbody ) {
|
|
|
|
|
|
|
|
// String was a <table>, *may* have spurious <tbody>
|
2009-07-19 17:48:30 +02:00
|
|
|
var hasBody = rtbody.test(elem),
|
2009-09-07 22:55:36 +02:00
|
|
|
tbody = tag === "table" && !hasBody ?
|
2009-03-18 22:15:38 +01:00
|
|
|
div.firstChild && div.firstChild.childNodes :
|
|
|
|
|
2009-07-19 17:29:03 +02:00
|
|
|
// String was a bare <thead> or <tfoot>
|
|
|
|
wrap[1] == "<table>" && !hasBody ?
|
|
|
|
div.childNodes :
|
|
|
|
[];
|
2009-03-18 22:15:38 +01:00
|
|
|
|
2009-07-19 17:29:03 +02:00
|
|
|
for ( var j = tbody.length - 1; j >= 0 ; --j ) {
|
|
|
|
if ( jQuery.nodeName( tbody[ j ], "tbody" ) && !tbody[ j ].childNodes.length ) {
|
2009-03-18 22:15:38 +01:00
|
|
|
tbody[ j ].parentNode.removeChild( tbody[ j ] );
|
2009-07-19 17:29:03 +02:00
|
|
|
}
|
2009-03-18 22:15:38 +01:00
|
|
|
}
|
|
|
|
|
2009-07-19 17:29:03 +02:00
|
|
|
}
|
|
|
|
|
2009-03-18 22:15:38 +01:00
|
|
|
// IE completely kills leading whitespace when innerHTML is used
|
2009-07-19 17:51:00 +02:00
|
|
|
if ( !jQuery.support.leadingWhitespace && rleadingWhitespace.test( elem ) ) {
|
|
|
|
div.insertBefore( context.createTextNode( rleadingWhitespace.exec(elem)[0] ), div.firstChild );
|
2009-07-19 17:29:03 +02:00
|
|
|
}
|
2009-03-23 02:55:17 +01:00
|
|
|
|
2009-03-18 22:15:38 +01:00
|
|
|
elem = jQuery.makeArray( div.childNodes );
|
|
|
|
}
|
|
|
|
|
2009-07-19 17:29:03 +02:00
|
|
|
if ( elem.nodeType ) {
|
2009-03-18 22:15:38 +01:00
|
|
|
ret.push( elem );
|
2009-07-19 17:29:03 +02:00
|
|
|
} else {
|
2009-03-18 22:15:38 +01:00
|
|
|
ret = jQuery.merge( ret, elem );
|
2009-07-19 17:29:03 +02:00
|
|
|
}
|
2009-03-18 22:15:38 +01:00
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
if ( fragment ) {
|
|
|
|
for ( var i = 0; ret[i]; i++ ) {
|
2009-09-07 20:58:01 +02:00
|
|
|
if ( scripts && jQuery.nodeName( ret[i], "script" ) && (!ret[i].type || ret[i].type.toLowerCase() === "text/javascript") ) {
|
2009-03-18 22:15:38 +01:00
|
|
|
scripts.push( ret[i].parentNode ? ret[i].parentNode.removeChild( ret[i] ) : ret[i] );
|
|
|
|
} else {
|
2009-07-19 17:48:30 +02:00
|
|
|
if ( ret[i].nodeType === 1 ) {
|
2009-03-18 22:15:38 +01:00
|
|
|
ret.splice.apply( ret, [i + 1, 0].concat(jQuery.makeArray(ret[i].getElementsByTagName("script"))) );
|
2009-07-19 17:48:30 +02:00
|
|
|
}
|
2009-03-18 22:15:38 +01:00
|
|
|
fragment.appendChild( ret[i] );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
function cleanData( elems ) {
|
2009-09-15 17:56:18 +02:00
|
|
|
for ( var i = 0, elem, id; (elem = elems[i]) != null; i++ ) {
|
2009-12-08 00:08:06 +01:00
|
|
|
if ( !jQuery.noData[elem.nodeName.toLowerCase()] && (id = elem[expando]) ) {
|
2009-03-18 22:15:38 +01:00
|
|
|
delete jQuery.cache[ id ];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|