diff options
author | John Resig <jeresig@gmail.com> | 2009-07-14 23:28:07 +0000 |
---|---|---|
committer | John Resig <jeresig@gmail.com> | 2009-07-14 23:28:07 +0000 |
commit | 991dafae16e44512c5107b90bc8ce9675d8f5c12 (patch) | |
tree | fe1dd78a8413b2c39997b30fb4181cf6becfe5d0 /test | |
parent | ad5ba1a72ef90c4327e3eb3ee133fbf87e181638 (diff) | |
download | jquery-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.js | 7 |
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() { |