Rename internal .getText to maintain parity between it and the primary .text(). Fixes...
[jquery.git] / src / manipulation.js
index 543bbcd..b2a9df9 100644 (file)
@@ -4,8 +4,8 @@ var rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g,
        rselfClosing = /^(?:area|br|col|embed|hr|img|input|link|meta|param)$/i,
        rtagName = /<([\w:]+)/,
        rtbody = /<tbody/i,
-       rhtml = /<|&\w+;/,
-       rnocache = /<script|<object|<embed/i,
+       rhtml = /<|&#?\w+;/,
+       rnocache = /<script|<object|<embed|<option/i,
        rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,  // checked="checked" or checked (html5)
        fcloseTag = function( all, front, tag ) {
                return rselfClosing.test( tag ) ?
@@ -45,7 +45,7 @@ jQuery.fn.extend({
                        return this.empty().append( (this[0] && this[0].ownerDocument || document).createTextNode( text ) );
                }
 
-               return jQuery.getText( this );
+               return jQuery.text( this );
        },
 
        wrapAll: function( html ) {
@@ -204,6 +204,8 @@ 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(rleadingWhitespace, "")], ownerDocument)[0];
                        } else {
                                return this.cloneNode(true);
@@ -266,16 +268,17 @@ jQuery.fn.extend({
                if ( this[0] && this[0].parentNode ) {
                        // Make sure that the elements are removed from the DOM before they are inserted
                        // this can help fix replacing a parent with child elements
-                       if ( !jQuery.isFunction( value ) ) {
-                               value = jQuery( value ).detach();
-
-                       } else {
+                       if ( jQuery.isFunction( value ) ) {
                                return this.each(function(i) {
                                        var self = jQuery(this), old = self.html();
                                        self.replaceWith( value.call( this, i, old ) );
                                });
                        }
 
+                       if ( typeof value !== "string" ) {
+                               value = jQuery(value).detach();
+                       }
+
                        return this.each(function() {
                                var next = this.nextSibling, parent = this.parentNode;