Commit d638aa9c authored by Dave Methvin's avatar Dave Methvin

Allow more cases to use `innerHTML` in the `.html` method.

Thanks @cmcnulty for the pull and the patience!
parents a4cdbf09 2746d7f2
...@@ -6,6 +6,7 @@ var rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g, ...@@ -6,6 +6,7 @@ var rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g,
rtagName = /<([\w:]+)/, rtagName = /<([\w:]+)/,
rtbody = /<tbody/i, rtbody = /<tbody/i,
rhtml = /<|&#?\w+;/, rhtml = /<|&#?\w+;/,
rnoInnerhtml = /<(?:script|style)/i,
rnocache = /<(?:script|object|embed|option|style)/i, rnocache = /<(?:script|object|embed|option|style)/i,
// checked="checked" or checked // checked="checked" or checked
rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i, rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
...@@ -217,7 +218,7 @@ jQuery.fn.extend({ ...@@ -217,7 +218,7 @@ jQuery.fn.extend({
null; null;
// See if we can take a shortcut and just use innerHTML // See if we can take a shortcut and just use innerHTML
} else if ( typeof value === "string" && !rnocache.test( value ) && } else if ( typeof value === "string" && !rnoInnerhtml.test( value ) &&
(jQuery.support.leadingWhitespace || !rleadingWhitespace.test( value )) && (jQuery.support.leadingWhitespace || !rleadingWhitespace.test( value )) &&
!wrapMap[ (rtagName.exec( value ) || ["", ""])[1].toLowerCase() ] ) { !wrapMap[ (rtagName.exec( value ) || ["", ""])[1].toLowerCase() ] ) {
......
...@@ -991,7 +991,7 @@ test("clone() (#8070)", function () { ...@@ -991,7 +991,7 @@ test("clone() (#8070)", function () {
}); });
test("clone()", function() { test("clone()", function() {
expect(37); expect(40);
equals( "This is a normal link: Yahoo", jQuery("#en").text(), "Assert text for #en" ); equals( "This is a normal link: Yahoo", jQuery("#en").text(), "Assert text for #en" );
var clone = jQuery("#yahoo").clone(); var clone = jQuery("#yahoo").clone();
equals( "Try them out:Yahoo", jQuery("#first").append(clone).text(), "Check for clone" ); equals( "Try them out:Yahoo", jQuery("#first").append(clone).text(), "Check for clone" );
...@@ -1058,6 +1058,14 @@ test("clone()", function() { ...@@ -1058,6 +1058,14 @@ test("clone()", function() {
cloneEvt.remove(); cloneEvt.remove();
divEvt.remove(); divEvt.remove();
// Test both html() and clone() for <embed and <object types
div = jQuery("<div/>").html('<embed height="355" width="425" src="http://www.youtube.com/v/3KANI2dpXLw&amp;hl=en"></embed>');
clone = div.clone(true);
equals( clone.length, 1, "One element cloned" );
equals( clone.html(), div.html(), "Element contents cloned" );
equals( clone[0].nodeName.toUpperCase(), "DIV", "DIV element cloned" );
// this is technically an invalid object, but because of the special // this is technically an invalid object, but because of the special
// classid instantiation it is the only kind that IE has trouble with, // classid instantiation it is the only kind that IE has trouble with,
// so let's test with it too. // so let's test with it too.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment