[Webkit-unassigned] [Bug 15274] Javascript bug in GetElementsByName or RemoveChild or InsertBefore ?
bugzilla-daemon at webkit.org
bugzilla-daemon at webkit.org
Tue Sep 25 14:01:50 PDT 2007
http://bugs.webkit.org/show_bug.cgi?id=15274
------- Comment #8 from bernu at lptmc.jussieu.fr 2007-09-25 14:01 PDT -------
I think I found the real problem.
(http://www.lptl.jussieu.fr/users/bernu/pub/fred.html)
the Javascript is reduced to
function del( ){
var divs = document.getElementsByName( "my_a" ) ;
divs[0].parentNode.removeChild( divs[ 0 ] ) ;
console.log( divs.length ) ;
console.log( divs[0].id ) ;
console.log( divs[1].id ) ;
}
and the HTML to
<body>
<div href="" id="a-1" name="my_a" >div 1</div>
<div href="" id="a-2" name="my_a" >div 2</div>
<input type="submit" onclick="del() ; return false;" />
</body>
The result in the console is
2
a-1
Null value error on line accessing divs[1].id
What I understand is :
getElementsByName gives a list of 2 nodes.
Removing the first div leaves the nodeList divs with 2 elements.
Accessing the first element surprinsingly worked here (but might not in a
more complicate case)
Accessing the second element fails on Safari.
On FireFox, the result is more consistent :
1
a-2
error divs[1] has no property.
Thus, removing an element in a list is the problem that WebKit is not doing as
other browsers.
After removing divs[0], divs.length=1
--
Configure bugmail: http://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
More information about the webkit-unassigned
mailing list