Use node.value and fallback to node.nodeValue where appropriate. Cache isAttr instead of accessing attrs.is twice.