We don't do end of line comments, move them above.
[jquery.git] / src / manipulation.js
index c3b8f6d..99d51a8 100644 (file)
@@ -2,18 +2,14 @@
 
 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 = /<tbody/i,
        rhtml = /<|&#?\w+;/,
-       rnocache = /<script|<object|<embed|<option|<style/i,
-       rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,  // checked="checked" or checked (html5)
-       fcloseTag = function( all, front, tag ) {
-               return rselfClosing.test( tag ) ?
-                       all :
-                       front + "></" + tag + ">";
-       },
+       rnocache = /<(?:script|object|embed|option|style)/i,
+       // checked="checked" or checked (html5)
+       rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
+       raction = /\=([^="'>\s]+\/)>/g,
        wrapMap = {
                option: [ 1, "<select multiple='multiple'>", "</select>" ],
                legend: [ 1, "<fieldset>", "</fieldset>" ],
@@ -207,7 +203,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);
@@ -235,7 +231,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></$2>");
 
                        try {
                                for ( var i = 0, l = this.length; i < l; i++ ) {
@@ -253,10 +249,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 {
@@ -479,7 +473,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></$2>");
 
                                // Trim whitespace, otherwise indexOf won't work as expected
                                var tag = (rtagName.exec( elem ) || ["", ""])[1].toLowerCase(),