X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;ds=inline;f=src%2Fmanipulation.js;h=e1657a8cf58b65ea9f4e02b7f6e16e41f56be355;hb=59802928566b6be3a66d65e77c2418fff37e6f5f;hp=4746dc83b1e70228a7d830c32b5781901399a538;hpb=173c1477ae6efc4c2eeb7131ba0646c4e1323975;p=jquery.git
diff --git a/src/manipulation.js b/src/manipulation.js
index 4746dc8..e1657a8 100644
--- a/src/manipulation.js
+++ b/src/manipulation.js
@@ -1,9 +1,10 @@
var rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g,
rleadingWhitespace = /^\s+/,
- rxhtmlTag = /(<(\w+)[^>]*?)\/>/g,
+ rxhtmlTag = /(<([\w:]+)[^>]*?)\/>/g,
rselfClosing = /^(?:abbr|br|col|img|input|link|meta|param|hr|area|embed)$/i,
- rtagName = /<(\w+)/,
+ rtagName = /<([\w:]+)/,
rtbody = /
", "" ],
td: [ 3, "" ],
col: [ 2, "" ],
+ area: [ 1, "" ],
_default: [ 0, "", "" ]
};
@@ -30,22 +32,11 @@ if ( !jQuery.support.htmlSerialize ) {
jQuery.fn.extend({
text: function( text ) {
- if ( typeof text !== "object" && text !== undefined )
+ if ( typeof text !== "object" && text !== undefined ) {
return this.empty().append( (this[0] && this[0].ownerDocument || document).createTextNode( text ) );
+ }
- var ret = "";
-
- jQuery.each( text || this, function(){
- jQuery.each( this.childNodes, function(){
- if ( this.nodeType !== 8 ) {
- ret += this.nodeType !== 1 ?
- this.nodeValue :
- jQuery.fn.text( [ this ] );
- }
- });
- });
-
- return ret;
+ return jQuery.getText( this );
},
wrapAll: function( html ) {
@@ -89,6 +80,14 @@ jQuery.fn.extend({
});
},
+ unwrap: function() {
+ return this.parent().each(function(){
+ if ( !jQuery.nodeName( this, "body" ) ) {
+ jQuery( this ).replaceWith( this.childNodes );
+ }
+ }).end();
+ },
+
append: function() {
return this.domManip(arguments, true, function(elem){
if ( this.nodeType === 1 ) {
@@ -110,12 +109,10 @@ jQuery.fn.extend({
return this.domManip(arguments, false, function(elem){
this.parentNode.insertBefore( elem, this );
});
- } else {
- var set = jQuery.isFunction(arguments[0]) ?
- jQuery( arguments[0]() ) :
- jQuery.apply(jQuery, arguments);
-
- return this.pushStack( set.add( this ), "before", arguments );
+ } else if ( arguments.length ) {
+ var set = jQuery(arguments[0]);
+ set.push.apply( set, this.toArray() );
+ return this.pushStack( set, "before", arguments );
}
},
@@ -124,10 +121,10 @@ jQuery.fn.extend({
return this.domManip(arguments, false, function(elem){
this.parentNode.insertBefore( elem, this.nextSibling );
});
- } else {
- return jQuery.isFunction(arguments[0]) ?
- this.add( arguments[0]() ) :
- this.add.apply( this, arguments );
+ } else if ( arguments.length ) {
+ var set = this.pushStack( this, "after", arguments );
+ set.push.apply( set, jQuery(arguments[0]).toArray() );
+ return set;
}
},
@@ -159,21 +156,8 @@ jQuery.fn.extend({
// Copy the events from the original to the clone
if ( events === true ) {
- var orig = this.find("*").andSelf(), i = 0;
-
- ret.find("*").andSelf().each(function(){
- if ( this.nodeName !== 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 );
- }
- }
-
- i++;
- });
+ cloneCopyEvent( this, ret );
+ cloneCopyEvent( this.find("*"), ret.find("*") );
}
// Return the cloned set
@@ -188,15 +172,21 @@ jQuery.fn.extend({
// See if we can take a shortcut and just use innerHTML
} else if ( typeof value === "string" && !/