aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorJohn Resig <jeresig@gmail.com>2009-07-14 23:28:07 +0000
committerJohn Resig <jeresig@gmail.com>2009-07-14 23:28:07 +0000
commit991dafae16e44512c5107b90bc8ce9675d8f5c12 (patch)
treefe1dd78a8413b2c39997b30fb4181cf6becfe5d0 /test
parentad5ba1a72ef90c4327e3eb3ee133fbf87e181638 (diff)
downloadjquery-991dafae16e44512c5107b90bc8ce9675d8f5c12.tar.gz
jquery-991dafae16e44512c5107b90bc8ce9675d8f5c12.zip
Fixed wrapping of elements that hold text nodes. Thanks to David Flanagan for the patch. Fixes #4902.
Diffstat (limited to 'test')
-rw-r--r--test/unit/manipulation.js7
1 files changed, 6 insertions, 1 deletions
diff --git a/test/unit/manipulation.js b/test/unit/manipulation.js
index d8dbca96c..ca185a47e 100644
--- a/test/unit/manipulation.js
+++ b/test/unit/manipulation.js
@@ -10,7 +10,7 @@ test("text()", function() {
});
var testWrap = function(val) {
- expect(10);
+ expect(12);
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' );
@@ -40,6 +40,11 @@ var testWrap = function(val) {
j = jQuery("<label/>").wrap(val( "<li/>" ));
equals( j[0].nodeName.toUpperCase(), "LABEL", "Element is a label" );
equals( j[0].parentNode.nodeName.toUpperCase(), "LI", "Element has been wrapped" );
+
+ // Wrap an element containing a text node
+ j = jQuery("<span/>").wrap("<div>test</div>");
+ equals( j[0].previousSibling.nodeType, 3, "Make sure the previous node is a text element" );
+ equals( j[0].parentNode.nodeName.toUpperCase(), "DIV", "And that we're in the div element." );
}
test("wrap(String|Element)", function() {