Side navigation
#3 closed bug (fixed)
Opened June 11, 2006 12:15AM UTC
Closed June 16, 2006 01:51AM UTC
Last modified June 20, 2007 01:39AM UTC
DOM insertion methods fail on elements that have a length property
| Reported by: | Klaus Hartl | Owned by: | |
|---|---|---|---|
| Priority: | major | Milestone: | 1.0 |
| Component: | core | Version: | 1.0 |
| Keywords: | dom insertion | Cc: | |
| Blocked by: | Blocking: |
Description
The DOM insertion methods append/prepend/before/after fail on elements that have a length property, like a form or text node:
The problem lies in $.clean, proposed fix (tested):
$.clean = function(a) {
var r = [];
for ( var i = 0; i < a.length; i++ )
if ( a[i].constructor == String ) {
var div = document.createElement("div");
div.innerHTML = a[i];
for ( var j = 0; j < div.childNodes.length; j++ )
r[r.length] = div.childNodes[j];
} else if ( a[i].length && !a[i].nodeType ) // added fix for nodes with length property (form, text node)
for ( var j = 0; j < a[i].length; j++ )
r[r.length] = a[i][j];
else if ( a[i] != null )
r[r.length] =
a[i].nodeType ? a[i] : document.createTextNode(a[i].toString());
return r;
};
Attachments (0)
Change History (1)
Changed June 16, 2006 01:51AM UTC by comment:1
| resolution: | → fixed |
|---|---|
| status: | new → closed |
Fixed in SVN #78. Thanks for the find, Klaus!