Try returning fragment.firstChild.content
instead of fragment.firstChild
.
Since this appears to vary slightly by browser, a better solution would be something like this:
var toReturn = fragment.firstChild;
return (toReturn.content ? toReturn.content : toReturn.childNodes);
It looks like there's some confusion by browser about whether the childNodes
is needed as well - with the above code, you can probably remove childNodes
from the console.log()
statements.