Socket
Socket
Sign inDemoInstall

css-what

Package Overview
Dependencies
0
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 4.0.0 to 5.0.0

3

lib/parse.d.ts

@@ -14,2 +14,3 @@ export interface Options {

* When `true`, `xmlMode` implies both `lowerCaseTags` and `lowerCaseAttributeNames` are set to `false`.
* Also, `ignoreCase` on attributes will not be inferred based on HTML rules anymore.
* @default false

@@ -25,3 +26,3 @@ */

value: string;
ignoreCase: boolean;
ignoreCase: boolean | null;
namespace: string | null;

@@ -28,0 +29,0 @@ }

"use strict";
var __spreadArrays = (this && this.__spreadArrays) || function () {
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
for (var r = Array(s), k = 0, i = 0; i < il; i++)
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
r[k] = a[j];
return r;
var __spreadArray = (this && this.__spreadArray) || function (to, from) {
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
to[j] = from[i];
return to;
};

@@ -14,3 +12,3 @@ Object.defineProperty(exports, "__esModule", { value: true });

// Modified version of https://github.com/jquery/sizzle/blob/master/src/sizzle.js#L87
var reAttr = /^\s*(?:(\*|[-\w]*)\|)?((?:\\.|[\w\u00b0-\uFFFF-])+)\s*(?:(\S?)=\s*(?:(['"])((?:[^\\]|\\[^])*?)\4|(#?(?:\\.|[\w\u00b0-\uFFFF-])*)|)|)\s*([iI])?\]/;
var reAttr = /^\s*(?:(\*|[-\w]*)\|)?((?:\\.|[\w\u00b0-\uFFFF-])+)\s*(?:(\S?)=\s*(?:(['"])((?:[^\\]|\\[^])*?)\4|(#?(?:\\.|[\w\u00b0-\uFFFF-])*)|)|)\s*([iIsS])?\s*\]/;
var actionTypes = {

@@ -45,6 +43,60 @@ undefined: "exists",

]);
var traversalNames = new Set(__spreadArrays([
var traversalNames = new Set(__spreadArray([
"descendant"
], Object.keys(Traversals).map(function (k) { return Traversals[k]; })));
/**
* Attributes that are case-insensitive in HTML.
*
* @private
* @see https://html.spec.whatwg.org/multipage/semantics-other.html#case-sensitivity-of-selectors
*/
var caseInsensitiveAttributes = new Set([
"accept",
"accept-charset",
"align",
"alink",
"axis",
"bgcolor",
"charset",
"checked",
"clear",
"codetype",
"color",
"compact",
"declare",
"defer",
"dir",
"direction",
"disabled",
"enctype",
"face",
"frame",
"hreflang",
"http-equiv",
"lang",
"language",
"link",
"media",
"method",
"multiple",
"nohref",
"noresize",
"noshade",
"nowrap",
"readonly",
"rel",
"rev",
"rules",
"scope",
"scrolling",
"selected",
"shape",
"target",
"text",
"type",
"valign",
"valuetype",
"vlink",
]);
/**
* Checks whether a specific selector is a traversal.

@@ -150,2 +202,10 @@ * This is useful eg. in swapping the order of elements that

}
else if (firstChar === "/" &&
selector.charAt(selectorIndex + 1) === "*") {
var endIndex = selector.indexOf("*/", selectorIndex + 2);
if (endIndex < 0) {
throw new Error("Comment was not terminated");
}
selectorIndex = endIndex + 2;
}
else {

@@ -164,4 +224,5 @@ if (sawWS) {

value: getName(1),
ignoreCase: false,
namespace: null,
// TODO: Add quirksMode option, which makes `ignoreCase` `true` for HTML.
ignoreCase: options.xmlMode ? null : false,
});

@@ -176,3 +237,3 @@ }

}
var completeSelector = attributeMatch[0], _d = attributeMatch[1], namespace = _d === void 0 ? null : _d, baseName = attributeMatch[2], actionType = attributeMatch[3], _e = attributeMatch[5], quotedValue = _e === void 0 ? "" : _e, _f = attributeMatch[6], value = _f === void 0 ? quotedValue : _f, ignoreCase = attributeMatch[7];
var completeSelector = attributeMatch[0], _d = attributeMatch[1], namespace = _d === void 0 ? null : _d, baseName = attributeMatch[2], actionType = attributeMatch[3], _e = attributeMatch[5], quotedValue = _e === void 0 ? "" : _e, _f = attributeMatch[6], value = _f === void 0 ? quotedValue : _f, forceIgnore = attributeMatch[7];
selectorIndex += completeSelector.length + 1;

@@ -183,3 +244,12 @@ var name_2 = unescapeCSS(baseName);

}
tokens.push({
var ignoreCase =
// If the forceIgnore flag is set (either `i` or `s`), use that value
forceIgnore
? forceIgnore.toLowerCase() === "i"
: // If `xmlMode` is set, there are no rules; return `null`.
options.xmlMode
? null
: // Otherwise, use the `caseInsensitiveAttributes` list.
caseInsensitiveAttributes.has(name_2);
var attributeSelector = {
type: "attribute",

@@ -190,4 +260,5 @@ name: name_2,

namespace: namespace,
ignoreCase: !!ignoreCase,
});
ignoreCase: ignoreCase,
};
tokens.push(attributeSelector);
}

@@ -253,2 +324,6 @@ else if (firstChar === ":") {

else if (reName.test(selector.slice(selectorIndex))) {
if (selector.charAt(selectorIndex) === "|") {
namespace = "";
selectorIndex += 1;
}
name_4 = getName(0);

@@ -255,0 +330,0 @@ }

"use strict";
var __spreadArrays = (this && this.__spreadArrays) || function () {
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
for (var r = Array(s), k = 0, i = 0; i < il; i++)
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
r[k] = a[j];
return r;
var __spreadArray = (this && this.__spreadArray) || function (to, from) {
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
to[j] = from[i];
return to;
};

@@ -19,5 +17,5 @@ Object.defineProperty(exports, "__esModule", { value: true });

};
var charsToEscape = new Set(__spreadArrays(Object.keys(actionTypes)
var charsToEscape = new Set(__spreadArray(__spreadArray([], Object.keys(actionTypes)
.map(function (typeKey) { return actionTypes[typeKey]; })
.filter(Boolean), [
.filter(Boolean)), [
":",

@@ -86,3 +84,3 @@ "[",

}
return "[" + name_1 + actionTypes[token.action] + "='" + escapeName(token.value) + "'" + (token.ignoreCase ? "i" : "") + "]";
return "[" + name_1 + actionTypes[token.action] + "='" + escapeName(token.value) + "'" + (token.ignoreCase ? "i" : token.ignoreCase === false ? "s" : "") + "]";
}

@@ -95,3 +93,3 @@ }

function getNamespace(namespace) {
return namespace
return namespace !== null
? (namespace === "*" ? "*" : escapeName(namespace)) + "|"

@@ -98,0 +96,0 @@ : "";

@@ -5,4 +5,6 @@ {

"description": "a CSS selector parser",
"version": "4.0.0",
"funding": "https://github.com/sponsors/fb55",
"version": "5.0.0",
"funding": {
"url": "https://github.com/sponsors/fb55"
},
"repository": {

@@ -29,3 +31,2 @@ "url": "https://github.com/fb55/css-what"

},
"dependencies": {},
"devDependencies": {

@@ -38,3 +39,3 @@ "@types/jest": "^26.0.3",

"eslint": "^7.0.0",
"eslint-config-prettier": "^6.0.0",
"eslint-config-prettier": "^8.1.0",
"eslint-plugin-node": "^11.1.0",

@@ -41,0 +42,0 @@ "jest": "^26.0.1",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc