wrap(), wrapAll(), wrapInner()

wrap(), wrapAll(), wrapInner()


If the argument to a wrap function is a string that contains text, it
doesn't do what I'd expect it to.
For example: $("h1").wrap("<i>\u00a7</i>")
I'd expect that to wrap all h1 elements in <i> tags, with a section sign
(\u00a7) before the h1.
I think the following patch to wrapAll() fixes it. On the other hand,
it doesn't make this work: $("h1").wrap("<i>\u00a7<b></b></i>"), so
perhaps this is a documentation bug: maybe the docs just need to be more
explicit about the legal arguments to the wrap() methods.
    David
Index: manipulation.js
===================================================================
--- manipulation.js (revision 6415)
+++ manipulation.js (working copy)
@@ -28,7 +28,7 @@
wrap.map(function(){
var elem = this;
- while ( elem.firstChild )
+ while ( elem.firstChild &&
elem.firstChild.nodeType == 1)
elem = elem.firstChild;
return elem;