fix child method: off-by-one error: child(0) == child(1) #149

merged 2 commits into from Jul 26, 2012

4 participants

var doc = libxml.parseXmlString('<?xml version="1.0"?>' +
                                '<root><child1>text node 1</child1><child2>text node 2</child2></root>');

console.log("doc.root().length: " + doc.root().childNodes().length);

var child1 = doc.root().child(0);
var child2 = doc.root().child(1);
var child3 = doc.root().child(2);

console.log("child1 text: " + child1.text());
console.log("child2 text: " + child2.text());
console.log("child3 text: " + child3.text());

This code should crash on the last line: child3 is null.
However we get this output:

doc.root().length: 2
child1 text: text node 1
child2 text: text node 1
child3 text: text node 2

This pull request fails (merged 1fa4f5d into f4707b5).


This pull request passes (merged d2f398f into f4707b5).


This looks good, but the auto-merge isn't working and I'm not setup to do it on this laptop. Can someone land this change? If not I'll do it later this evening.

@defunctzombie defunctzombie merged commit 76696fa into libxmljs:master Jul 26, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment