@medv/finder
Advanced tools
Comparing version 1.0.4 to 1.0.5
@@ -56,2 +56,3 @@ "use strict"; | ||
var config; | ||
var rootDocument; | ||
function default_1(input, options) { | ||
@@ -73,2 +74,3 @@ if (input.nodeType !== Node.ELEMENT_NODE) { | ||
config = __assign({}, defaults, options); | ||
rootDocument = findRootDocument(config.root); | ||
var path = bottomUpSearch(input, Limit.All, function () { | ||
@@ -91,2 +93,5 @@ return bottomUpSearch(input, Limit.Two, function () { | ||
exports.default = default_1; | ||
function findRootDocument(rootNode) { | ||
return (rootNode.nodeType === Node.DOCUMENT_NODE) ? rootNode : rootNode.ownerDocument; | ||
} | ||
function bottomUpSearch(input, limit, fallback) { | ||
@@ -173,3 +178,3 @@ var path = null; | ||
function unique(path) { | ||
switch (document.querySelectorAll(selector(path)).length) { | ||
switch (rootDocument.querySelectorAll(selector(path)).length) { | ||
case 0: | ||
@@ -320,4 +325,4 @@ throw new Error("Can't select any node with this selector: " + selector(path)); | ||
function same(path, input) { | ||
return document.querySelector(selector(path)) === input; | ||
return rootDocument.querySelector(selector(path)) === input; | ||
} | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@medv/finder", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"description": "CSS Selector Generator", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
24746
331