From e9d3c259825d255506848219ede7beef1aed4efb Mon Sep 17 00:00:00 2001 From: jonmaber Date: Sun, 6 May 2018 14:05:47 +0100 Subject: [PATCH] Kind test matches text() to both parsed and not parsed character nodes. This is needed because, although CDATA_SECTION_NODE type is deprecated, popular browsers still use it. (They ought to convert incoming CDATA sections to TEXT_NODE.) --- src/kindTest.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/kindTest.js b/src/kindTest.js index dc71471..1e021d3 100644 --- a/src/kindTest.js +++ b/src/kindTest.js @@ -100,7 +100,8 @@ wgxpath.KindTest.isValidType = function(typeName) { * @override */ wgxpath.KindTest.prototype.matches = function(node) { - return goog.isNull(this.type_) || this.type_ == node.nodeType; + var efftype = node.nodeType == goog.dom.NodeType.CDATA_SECTION ? goog.dom.NodeType.TEXT : node.nodeType; + return goog.isNull(this.type_) || this.type_ == efftype; };