mirror of
https://github.com/jquery/jquery.git
synced 2024-11-23 02:54:22 +00:00
Clone fragments in domManip using jQuery.clone instead of DocumentFragment.cloneNode in order to carry over event data. Fixes #5566, #6997.
This commit is contained in:
parent
c8be9461ee
commit
e4900df838
@ -349,7 +349,7 @@ jQuery.fn.extend({
|
||||
root(this[i], first) :
|
||||
this[i],
|
||||
i > 0 || results.cacheable || this.length > 1 ?
|
||||
fragment.cloneNode(true) :
|
||||
jQuery(fragment).clone(true)[0] :
|
||||
fragment
|
||||
);
|
||||
}
|
||||
|
@ -381,6 +381,26 @@ test("append(Function) with incoming value", function() {
|
||||
QUnit.reset();
|
||||
});
|
||||
|
||||
test("append the same fragment with events (Bug #6997, 5566)", function () {
|
||||
expect(2);
|
||||
stop(1000);
|
||||
|
||||
var element = jQuery("<a class='test6997'></a>").click(function () {
|
||||
ok(true, "Append second element events work");
|
||||
});
|
||||
|
||||
jQuery("#listWithTabIndex li").append(element)
|
||||
.find('a.test6997').eq(1).click();
|
||||
|
||||
element = jQuery("<li class='test6997'></li>").click(function () {
|
||||
ok(true, "Before second element events work");
|
||||
start();
|
||||
});
|
||||
|
||||
jQuery("#listWithTabIndex li").before(element);
|
||||
jQuery("#listWithTabIndex li.test6997").eq(1).click();
|
||||
});
|
||||
|
||||
test("appendTo(String|Element|Array<Element>|jQuery)", function() {
|
||||
expect(16);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user