mirror of
https://github.com/jquery/jquery.git
synced 2024-11-23 02:54:22 +00:00
Fix #8894. Ensure .appendTo
creates a new set in oldIE.
This commit is contained in:
parent
8fadc5ba01
commit
abd2a07498
@ -801,7 +801,7 @@ jQuery.extend({
|
|||||||
return proxy;
|
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
|
// The value/s can optionally be executed if it's a function
|
||||||
access: function( elems, fn, key, value, chainable, emptyGet, pass ) {
|
access: function( elems, fn, key, value, chainable, emptyGet, pass ) {
|
||||||
var exec,
|
var exec,
|
||||||
|
@ -40,7 +40,8 @@ var nodeNames = "abbr|article|aside|audio|bdi|canvas|data|datalist|details|figca
|
|||||||
area: [ 1, "<map>", "</map>" ],
|
area: [ 1, "<map>", "</map>" ],
|
||||||
_default: [ 0, "", "" ]
|
_default: [ 0, "", "" ]
|
||||||
},
|
},
|
||||||
safeFragment = createSafeFragment( document );
|
safeFragment = createSafeFragment( document ),
|
||||||
|
fragmentDiv = safeFragment.appendChild( document.createElement("div") );
|
||||||
|
|
||||||
wrapMap.optgroup = wrapMap.option;
|
wrapMap.optgroup = wrapMap.option;
|
||||||
wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
|
wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
|
||||||
@ -529,7 +530,7 @@ jQuery.each({
|
|||||||
insert = jQuery( selector ),
|
insert = jQuery( selector ),
|
||||||
parent = this.length === 1 && this[0].parentNode;
|
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] );
|
insert[ original ]( this[0] );
|
||||||
return this;
|
return this;
|
||||||
} else {
|
} 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({
|
jQuery.extend({
|
||||||
clone: function( elem, dataAndEvents, deepDataAndEvents ) {
|
clone: function( elem, dataAndEvents, deepDataAndEvents ) {
|
||||||
var srcElements,
|
var srcElements,
|
||||||
destElements,
|
destElements,
|
||||||
i,
|
i,
|
||||||
// IE<=8 does not properly clone detached, unknown element nodes
|
clone;
|
||||||
clone = jQuery.support.html5Clone || jQuery.isXMLDoc(elem) || !rnoshimcache.test( "<" + elem.nodeName + ">" ) ?
|
|
||||||
elem.cloneNode( true ) :
|
if ( jQuery.support.html5Clone || jQuery.isXMLDoc(elem) || !rnoshimcache.test( "<" + elem.nodeName + ">" ) ) {
|
||||||
shimCloneNode( elem );
|
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) &&
|
if ( (!jQuery.support.noCloneEvent || !jQuery.support.noCloneChecked) &&
|
||||||
(elem.nodeType === 1 || elem.nodeType === 11) && !jQuery.isXMLDoc(elem) ) {
|
(elem.nodeType === 1 || elem.nodeType === 11) && !jQuery.isXMLDoc(elem) ) {
|
||||||
|
@ -571,7 +571,7 @@ test("IE8 serialization bug", function () {
|
|||||||
test("html() object element #10324", function() {
|
test("html() object element #10324", function() {
|
||||||
expect( 1 );
|
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();
|
clone = object.clone();
|
||||||
|
|
||||||
equal( clone.html(), object.html(), "html() returns correct innerhtml of cloned object elements" );
|
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 ]" );
|
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" );
|
||||||
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user