aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorJohn Resig <jeresig@gmail.com>2009-12-08 11:21:24 -0800
committerJohn Resig <jeresig@gmail.com>2009-12-08 11:21:24 -0800
commitf5b649fafbd85a1973a9c46ca6bf163d9de857a7 (patch)
treea855fa21642e09365fd10bdd10566bbe2c518e53 /test
parent77510fec025e654a8d2fdc6b2cbb564c159b3204 (diff)
downloadjquery-f5b649fafbd85a1973a9c46ca6bf163d9de857a7.tar.gz
jquery-f5b649fafbd85a1973a9c46ca6bf163d9de857a7.zip
Make sure that events are cloned for wrap, fixes #2977.
Diffstat (limited to 'test')
-rw-r--r--test/unit/manipulation.js16
1 files changed, 15 insertions, 1 deletions
diff --git a/test/unit/manipulation.js b/test/unit/manipulation.js
index 44fafa92b..4631ead61 100644
--- a/test/unit/manipulation.js
+++ b/test/unit/manipulation.js
@@ -13,7 +13,7 @@ test("text()", function() {
});
var testWrap = function(val) {
- expect(15);
+ expect(18);
var defaultText = 'Try them out:'
var result = jQuery('#first').wrap(val( '<div class="red"><span></span></div>' )).text();
equals( defaultText, result, 'Check for wrapping of on-the-fly html' );
@@ -54,6 +54,20 @@ var testWrap = function(val) {
equals( j[0].parentNode.parentNode.childNodes.length, 1, "There should only be one element wrapping." );
equals( j.length, 1, "There should only be one element (no cloning)." );
equals( j[0].parentNode.nodeName.toUpperCase(), "P", "The span should be in the paragraph." );
+
+ // Wrap an element with a jQuery set
+ j = jQuery("<span/>").wrap(jQuery("<div></div>"));
+ equals( j[0].parentNode.nodeName.toLowerCase(), "div", "Wrapping works." );
+
+ // Wrap an element with a jQuery set and event
+ result = jQuery("<div></div>").click(function(){
+ ok(true, "Event triggered.");
+ });
+
+ j = jQuery("<span/>").wrap(result);
+ equals( j[0].parentNode.nodeName.toLowerCase(), "div", "Wrapping works." );
+
+ j.parent().trigger("click");
}
test("wrap(String|Element)", function() {