var rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g,
rleadingWhitespace = /^\s+/,
rxhtmlTag = /(<([\w:]+)[^>]*?)\/>/g,
- rselfClosing = /^(?:abbr|br|col|img|input|link|meta|param|hr|area|embed)$/i,
+ rselfClosing = /^(?:area|br|col|embed|hr|img|input|link|meta|param)$/i,
rtagName = /<([\w:]+)/,
rtbody = /<tbody/i,
rhtml = /<|&\w+;/,
jQuery.fn.extend({
text: function( text ) {
+ if(jQuery.isFunction(text)) {
+ return this.each(function() {
+ return jQuery(this).text( text.call(this) );
+ });
+ }
+
if ( typeof text !== "object" && text !== undefined ) {
return this.empty().append( (this[0] && this[0].ownerDocument || document).createTextNode( text ) );
}
- var ret = "";
-
- jQuery.each( this, function() {
- // Get the text from text nodes and CDATA nodes
- if ( this.nodeType === 3 || this.nodeType === 4 ) {
- ret += this.nodeValue;
-
- // Traverse everything else, except comment nodes
- } else if ( this.nodeType !== 8 ) {
- ret += jQuery.fn.text.call( this.childNodes );
- }
- });
-
- return ret;
+ return jQuery.getText( this );
},
wrapAll: function( html ) {
if ( this[0] ) {
// The elements to wrap the target around
- var wrap = jQuery( html, this[0].ownerDocument ).eq(0).clone();
+ var wrap = jQuery( html, this[0].ownerDocument ).eq(0).clone(true);
if ( this[0].parentNode ) {
wrap.insertBefore( this[0] );
}
}).end();
},
-
+
append: function() {
return this.domManip(arguments, true, function(elem){
if ( this.nodeType === 1 ) {
var i = 0;
ret.each(function(){
- if ( this.nodeName !== orig[i].nodeName ) {
+ if ( this.nodeName !== (orig[i] && orig[i].nodeName) ) {
return;
}
- var events = jQuery.data( orig[i], "events" );
-
- for ( var type in events ) {
- for ( var handler in events[ type ] ) {
- jQuery.event.add( this, type, events[ type ][ handler ], events[ type ][ handler ].data );
- }
- }
+ jQuery.data( this, jQuery.data( orig[i++] ) );
});
}
function cleanData( elems ) {
for ( var i = 0, elem, id; (elem = elems[i]) != null; i++ ) {
- if ( (id = elem[expando]) ) {
+ if ( !jQuery.noData[elem.nodeName.toLowerCase()] && (id = elem[expando]) ) {
delete jQuery.cache[ id ];
}
}