aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/core.js2
-rw-r--r--src/manipulation.js28
-rw-r--r--test/unit/manipulation.js10
3 files changed, 23 insertions, 17 deletions
diff --git a/src/core.js b/src/core.js
index 193dc1b34..4e38deaeb 100644
--- a/src/core.js
+++ b/src/core.js
@@ -801,7 +801,7 @@ jQuery.extend({
return proxy;
},
- // Mutifunctional method to get and set values to a collection
+ // Multifunctional method to get and set values of a collection
// The value/s can optionally be executed if it's a function
access: function( elems, fn, key, value, chainable, emptyGet, pass ) {
var exec,
diff --git a/src/manipulation.js b/src/manipulation.js
index da4f475b5..cc6acee82 100644
--- a/src/manipulation.js
+++ b/src/manipulation.js
@@ -40,7 +40,8 @@ var nodeNames = "abbr|article|aside|audio|bdi|canvas|data|datalist|details|figca
area: [ 1, "<map>", "</map>" ],
_default: [ 0, "", "" ]
},
- safeFragment = createSafeFragment( document );
+ safeFragment = createSafeFragment( document ),
+ fragmentDiv = safeFragment.appendChild( document.createElement("div") );
wrapMap.optgroup = wrapMap.option;
wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
@@ -529,7 +530,7 @@ jQuery.each({
insert = jQuery( selector ),
parent = this.length === 1 && this[0].parentNode;
- if ( parent && parent.nodeType === 11 && parent.childNodes.length === 1 && insert.length === 1 ) {
+ if ( (parent == null || parent && parent.nodeType === 11 && parent.childNodes.length === 1) && insert.length === 1 ) {
insert[ original ]( this[0] );
return this;
} else {
@@ -563,24 +564,21 @@ function fixDefaultChecked( elem ) {
}
}
-// Derived From: http://www.iecss.com/shimprove/javascript/shimprove.1-0-1.js
-function shimCloneNode( elem ) {
- var div = document.createElement( "div" );
- safeFragment.appendChild( div );
-
- div.innerHTML = elem.outerHTML;
- return div.firstChild;
-}
-
jQuery.extend({
clone: function( elem, dataAndEvents, deepDataAndEvents ) {
var srcElements,
destElements,
i,
- // IE<=8 does not properly clone detached, unknown element nodes
- clone = jQuery.support.html5Clone || jQuery.isXMLDoc(elem) || !rnoshimcache.test( "<" + elem.nodeName + ">" ) ?
- elem.cloneNode( true ) :
- shimCloneNode( elem );
+ clone;
+
+ if ( jQuery.support.html5Clone || jQuery.isXMLDoc(elem) || !rnoshimcache.test( "<" + elem.nodeName + ">" ) ) {
+ clone = elem.cloneNode( true );
+
+ // IE<=8 does not properly clone detached, unknown element nodes
+ } else {
+ fragmentDiv.innerHTML = elem.outerHTML;
+ fragmentDiv.removeChild( clone = fragmentDiv.firstChild );
+ }
if ( (!jQuery.support.noCloneEvent || !jQuery.support.noCloneChecked) &&
(elem.nodeType === 1 || elem.nodeType === 11) && !jQuery.isXMLDoc(elem) ) {
diff --git a/test/unit/manipulation.js b/test/unit/manipulation.js
index 4aae3e28e..672b204e1 100644
--- a/test/unit/manipulation.js
+++ b/test/unit/manipulation.js
@@ -571,7 +571,7 @@ test("IE8 serialization bug", function () {
test("html() object element #10324", function() {
expect( 1 );
- var object = jQuery("<object id='object2'><param name='object2test' value='test'></param></object>​").appendTo("#qunit-fixture"),
+ var object = jQuery("<object id='object2'><param name='object2test' value='test'></param></object>?").appendTo("#qunit-fixture"),
clone = object.clone();
equal( clone.html(), object.html(), "html() returns correct innerhtml of cloned object elements" );
@@ -1776,3 +1776,11 @@ test("Guard against exceptions when clearing safeChildNodes", function() {
ok( div && div.jquery, "Created nodes safely, guarded against exceptions on safeChildNodes[ -1 ]" );
});
+
+test("Ensure oldIE creates a new set on appendTo (#8894)", function() {
+ strictEqual( jQuery("<div/>").clone().addClass("test").appendTo("<div/>").end().hasClass("test"), false, "Check jQuery.fn.appendTo after jQuery.clone" );
+ strictEqual( jQuery("<div/>").find("p").end().addClass("test").appendTo("<div/>").end().hasClass("test"), false, "Check jQuery.fn.appendTo after jQuery.fn.find" );
+ strictEqual( jQuery("<div/>").text("test").addClass("test").appendTo("<div/>").end().hasClass("test"), false, "Check jQuery.fn.appendTo after jQuery.fn.text" );
+ strictEqual( jQuery("<bdi/>").clone().addClass("test").appendTo("<div/>").end().hasClass("test"), false, "Check jQuery.fn.appendTo after clone html5 element" );
+ strictEqual( jQuery("<p/>").appendTo("<div/>").end().length, jQuery("<p>test</p>").appendTo("<div/>").end().length, "Elements created with createElement and with createDocumentFragment should be treated alike" );
+});