This is a browser inconsistency. Not a bad one, in my view, because the selection is reasonable in either case, but it's still an inconsistency. The easiest workaround is to create a range that explicitly selects the text node, which will remain unscathed after being added to the selection in all major browsers. Rather than
rangy.getSelection().selectAllChildren(newParent);
... I suggest
var newRange = rangy.createRange();
newRange.setStart(newParent.firstChild, 0);
var lastChild = newParent.lastChild;
newRange.setEnd(lastChild,
lastChild.nodeType == 3 ? lastChild.length : lastChild.childNodes.length);
rangy.getSelection().setSingleRange(newRange);
The problem is that WebKit mangles ranges as they are added to the selection. The range you create was the same in all browsers but got altered in some browsers when added to the selection, but not Firefox.