From 023367ec6045e404a3d1e306b990be5aab4cf36c Mon Sep 17 00:00:00 2001 From: Jason Miller Date: Tue, 3 Apr 2018 17:00:07 -0400 Subject: [PATCH] Switch nwmatcher from thinking we're a DocumentFragment to thinking we're a proper Document. --- config/critters-webpack-plugin.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/config/critters-webpack-plugin.js b/config/critters-webpack-plugin.js index c46772f2..50068238 100644 --- a/config/critters-webpack-plugin.js +++ b/config/critters-webpack-plugin.js @@ -235,7 +235,7 @@ function getElementsByTagName(tagName) { const ElementExtensions = { nodeName: { get() { - return this.tagName; + return this.tagName.toUpperCase(); } }, insertBefore(child, referenceNode) { @@ -279,7 +279,12 @@ const DocumentExtensions = { // nwmatcher requires that it at least report a correct nodeType of DOCUMENT_NODE. nodeType: { get() { - return 11; + return 9; + } + }, + nodeName: { + get() { + return '#document'; } }, createElement(name) { @@ -295,10 +300,10 @@ const DocumentExtensions = { return node; }, querySelector(sel) { - return this.$match.first(sel); + return this.$match.first(sel, this.documentElement); }, querySelectorAll(sel) { - return this.$match.select(sel); + return this.$match.select(sel, this.documentElement); }, getElementsByTagName, // nwmatcher uses inexistence of `document.addEventListener` to detect IE: