diff options
author | Dave Methvin <dave.methvin@gmail.com> | 2011-09-21 23:05:26 -0400 |
---|---|---|
committer | Dave Methvin <dave.methvin@gmail.com> | 2011-09-21 23:05:26 -0400 |
commit | d638aa9c6d6394db0c06431560b3d8b83cacc61c (patch) | |
tree | 95d9817d17be43e69c51186b127371c15952fd43 | |
parent | a4cdbf09ee97471ec041d83ceb8f3feb9825b2a1 (diff) | |
parent | 2746d7f29976462499fa98181986f47c75258c94 (diff) | |
download | jquery-d638aa9c6d6394db0c06431560b3d8b83cacc61c.tar.gz jquery-d638aa9c6d6394db0c06431560b3d8b83cacc61c.zip |
Allow more cases to use `innerHTML` in the `.html` method.
Thanks @cmcnulty for the pull and the patience!
-rw-r--r-- | src/manipulation.js | 3 | ||||
-rw-r--r-- | test/unit/manipulation.js | 10 |
2 files changed, 11 insertions, 2 deletions
diff --git a/src/manipulation.js b/src/manipulation.js index bc2af18dc..8b0af08a9 100644 --- a/src/manipulation.js +++ b/src/manipulation.js @@ -6,6 +6,7 @@ var rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g, rtagName = /<([\w:]+)/, rtbody = /<tbody/i, rhtml = /<|&#?\w+;/, + rnoInnerhtml = /<(?:script|style)/i, rnocache = /<(?:script|object|embed|option|style)/i, // checked="checked" or checked rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i, @@ -217,7 +218,7 @@ jQuery.fn.extend({ null; // 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 )) && !wrapMap[ (rtagName.exec( value ) || ["", ""])[1].toLowerCase() ] ) { diff --git a/test/unit/manipulation.js b/test/unit/manipulation.js index 64c07498b..c60c3201d 100644 --- a/test/unit/manipulation.js +++ b/test/unit/manipulation.js @@ -991,7 +991,7 @@ test("clone() (#8070)", function () { }); test("clone()", function() { - expect(37); + expect(40); equals( "This is a normal link: Yahoo", jQuery("#en").text(), "Assert text for #en" ); var clone = jQuery("#yahoo").clone(); equals( "Try them out:Yahoo", jQuery("#first").append(clone).text(), "Check for clone" ); @@ -1058,6 +1058,14 @@ test("clone()", function() { cloneEvt.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&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 // classid instantiation it is the only kind that IE has trouble with, // so let's test with it too. |