Comparing version 2.0.1 to 2.0.2
42
index.js
@@ -95,27 +95,29 @@ /** | ||
if (global.document) { | ||
var validSelectorCache = {}; | ||
var testSelectorElement = global.document.createElement('div'); | ||
var validSelectorCache = {}; | ||
var testSelectorElement = null; | ||
exports.isSelectorValid = function(selector) { | ||
var valid = validSelectorCache[selector]; | ||
if (valid === undefined) { | ||
try { | ||
testSelectorElement.querySelector(selector); | ||
valid = true; | ||
} catch (error) { | ||
valid = false; | ||
} | ||
validSelectorCache[selector] = valid; | ||
exports.isSelectorValid = function(selector) { | ||
var valid = validSelectorCache[selector]; | ||
if (valid === undefined) { | ||
if (testSelectorElement == null) { | ||
testSelectorElement = document.createElement('div') | ||
} | ||
return valid; | ||
} | ||
exports.validateSelector = function(selector) { | ||
if (!exports.isSelectorValid(selector)) { | ||
var error = new SyntaxError(selector + ' is not a valid selector'); | ||
error.code = 'EBADSELECTOR'; | ||
throw error; | ||
try { | ||
testSelectorElement.querySelector(selector); | ||
valid = true; | ||
} catch (error) { | ||
valid = false; | ||
} | ||
validSelectorCache[selector] = valid; | ||
} | ||
return valid; | ||
} | ||
exports.validateSelector = function(selector) { | ||
if (!exports.isSelectorValid(selector)) { | ||
var error = new SyntaxError(selector + ' is not a valid selector'); | ||
error.code = 'EBADSELECTOR'; | ||
throw error; | ||
} | ||
} |
{ | ||
"name": "clear-cut", | ||
"version": "2.0.1", | ||
"version": "2.0.2", | ||
"description": "Calculate specificity of CSS selectors", | ||
@@ -8,3 +8,3 @@ "main": "./index.js", | ||
"benchmark": "coffee benchmark/benchmark.coffee", | ||
"test": "node node_modules/.bin/jasmine-focused --coffee --captureExceptions spec" | ||
"test": "node_modules/.bin/jasmine-focused --coffee --captureExceptions spec" | ||
}, | ||
@@ -11,0 +11,0 @@ "license": "MIT", |
@@ -1,2 +0,4 @@ | ||
# clear cut [![Build Status](https://travis-ci.org/atom/clear-cut.png?branch=master)](https://travis-ci.org/atom/clear-cut) | ||
# Clear cut | ||
[![OS X Build Status](https://travis-ci.org/atom/clear-cut.png?branch=master)](https://travis-ci.org/atom/clear-cut) | ||
[![Windows Build Status](https://ci.appveyor.com/api/projects/status/civ54x89l06286m9/branch/master?svg=true)](https://ci.appveyor.com/project/Atom/clear-cut/branch/master) [![Dependency Status](https://david-dm.org/atom/clear-cut.svg)](https://david-dm.org/atom/clear-cut) | ||
@@ -3,0 +5,0 @@ Calculate the specificity of a CSS selector |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
6806
5
100
28
1