X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=src%2Fmanipulation.js;h=325f303a8316d399a654c33f33926ee43fd34e62;hb=0368606c081fd15dfbcd8509734ef63c58a6b008;hp=cb898cc3ca109b16b60d48f63424cf1cff610d53;hpb=8effe3a7dee91c833cc1774646da9d743600c64c;p=jquery.git diff --git a/src/manipulation.js b/src/manipulation.js index cb898cc..325f303 100644 --- a/src/manipulation.js +++ b/src/manipulation.js @@ -1,17 +1,14 @@ +(function( jQuery ) { + var rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g, rleadingWhitespace = /^\s+/, - rxhtmlTag = /(<([\w:]+)[^>]*?)\/>/g, - rselfClosing = /^(?:area|br|col|embed|hr|img|input|link|meta|param)$/i, + rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig, rtagName = /<([\w:]+)/, rtbody = /"; - }, + raction = /\=([^="'>\s]+\/)>/g, wrapMap = { option: [ 1, "" ], legend: [ 1, "
", "
" ], @@ -205,7 +202,7 @@ jQuery.fn.extend({ return jQuery.clean([html.replace(rinlinejQuery, "") // Handle the case in IE 8 where action=/test/> self-closes a tag - .replace(/\=([^="'>\s]+\/)>/g, '="$1">') + .replace(raction, '="$1">') .replace(rleadingWhitespace, "")], ownerDocument)[0]; } else { return this.cloneNode(true); @@ -233,7 +230,7 @@ jQuery.fn.extend({ (jQuery.support.leadingWhitespace || !rleadingWhitespace.test( value )) && !wrapMap[ (rtagName.exec( value ) || ["", ""])[1].toLowerCase() ] ) { - value = value.replace(rxhtmlTag, fcloseTag); + value = value.replace(rxhtmlTag, "<$1>"); try { for ( var i = 0, l = this.length; i < l; i++ ) { @@ -251,10 +248,8 @@ jQuery.fn.extend({ } else if ( jQuery.isFunction( value ) ) { this.each(function(i){ - var self = jQuery(this), old = self.html(); - self.empty().append(function(){ - return value.call( this, i, old ); - }); + var self = jQuery(this); + self.html( value.call(this, i, self.html()) ); }); } else { @@ -325,7 +320,7 @@ jQuery.fn.extend({ results = { fragment: parent }; } else { - results = buildFragment( args, this, scripts ); + results = jQuery.buildFragment( args, this, scripts ); } fragment = results.fragment; @@ -390,7 +385,7 @@ function cloneCopyEvent(orig, ret) { }); } -function buildFragment( args, nodes, scripts ) { +jQuery.buildFragment = function( args, nodes, scripts ) { var fragment, cacheable, cacheresults, doc = (nodes && nodes[0] ? nodes[0].ownerDocument || nodes[0] : document); @@ -420,7 +415,7 @@ function buildFragment( args, nodes, scripts ) { } return { fragment: fragment, cacheable: cacheable }; -} +}; jQuery.fragments = {}; @@ -477,7 +472,7 @@ jQuery.extend({ } else if ( typeof elem === "string" ) { // Fix "XHTML"-style tags in all browsers - elem = elem.replace(rxhtmlTag, fcloseTag); + elem = elem.replace(rxhtmlTag, "<$1>"); // Trim whitespace, otherwise indexOf won't work as expected var tag = (rtagName.exec( elem ) || ["", ""])[1].toLowerCase(), @@ -567,7 +562,7 @@ jQuery.extend({ jQuery.event.remove( elem, type ); } else { - removeEvent( elem, type, data.handle ); + jQuery.removeEvent( elem, type, data.handle ); } } } @@ -599,4 +594,6 @@ function evalScript( i, elem ) { if ( elem.parentNode ) { elem.parentNode.removeChild( elem ); } -} \ No newline at end of file +} + +})( jQuery );