@medv/finder
Advanced tools
Comparing version 1.1.1 to 1.1.2
@@ -6,2 +6,3 @@ export declare type Options = { | ||
tagName: (name: string) => boolean; | ||
attr: (name: string, value: string) => boolean; | ||
seedMinLength: number; | ||
@@ -8,0 +9,0 @@ optimizedMinLength: number; |
@@ -65,3 +65,3 @@ "use strict"; | ||
if ('html' === input.tagName.toLowerCase()) { | ||
return input.tagName.toLowerCase(); | ||
return 'html'; | ||
} | ||
@@ -73,2 +73,3 @@ var defaults = { | ||
tagName: function (name) { return true; }, | ||
attr: function (name, value) { return false; }, | ||
seedMinLength: 1, | ||
@@ -112,3 +113,3 @@ optimizedMinLength: 2, | ||
var _loop_1 = function () { | ||
var level = maybe(id(current)) || maybe.apply(void 0, classNames(current)) || maybe(tagName(current)) || [any()]; | ||
var level = maybe(id(current)) || maybe.apply(void 0, attr(current)) || maybe.apply(void 0, classNames(current)) || maybe(tagName(current)) || [any()]; | ||
var nth = index(current); | ||
@@ -207,2 +208,9 @@ if (limit === Limit.All) { | ||
} | ||
function attr(input) { | ||
var attrs = Array.from(input.attributes).filter(function (attr) { return config.attr(attr.name, attr.value); }); | ||
return attrs.map(function (attr) { return ({ | ||
name: '[' + cssesc(attr.name, { isIdentifier: true }) + '="' + cssesc(attr.value) + '"]', | ||
penalty: 0.5 | ||
}); }); | ||
} | ||
function classNames(input) { | ||
@@ -209,0 +217,0 @@ var names = Array.from(input.classList) |
{ | ||
"name": "@medv/finder", | ||
"version": "1.1.1", | ||
"version": "1.1.2", | ||
"description": "CSS Selector Generator", | ||
@@ -35,3 +35,3 @@ "main": "dist/index.js", | ||
"release-it": "^7.6.1", | ||
"typescript": "^3.0.1" | ||
"typescript": "3.0.1" | ||
}, | ||
@@ -38,0 +38,0 @@ "ava": { |
@@ -22,2 +22,6 @@ ![finder](https://user-images.githubusercontent.com/141232/36463709-381f8c36-16fe-11e8-8fdc-fcbdd4f2a36c.png) | ||
<a href="https://www.patreon.com/antonmedv"> | ||
<img src="https://c5.patreon.com/external/logo/become_a_patron_button@2x.png" width="160"> | ||
</a> | ||
## Usage | ||
@@ -24,0 +28,0 @@ |
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
25941
351
130