summaryrefslogtreecommitdiff
path: root/includes/external/addressbook/node_modules/css-select/lib/esm/attributes.js
diff options
context:
space:
mode:
authorRaindropsSys <contact@minteck.org>2023-04-06 22:18:28 +0200
committerRaindropsSys <contact@minteck.org>2023-04-06 22:18:28 +0200
commit83354b2b88218090988dd6e526b0a2505b57e0f1 (patch)
treee3c73c38a122a78bb7e66fbb99056407edd9d4b9 /includes/external/addressbook/node_modules/css-select/lib/esm/attributes.js
parent47b8f2299a483024c4a6a8876af825a010954caa (diff)
downloadpluralconnect-83354b2b88218090988dd6e526b0a2505b57e0f1.tar.gz
pluralconnect-83354b2b88218090988dd6e526b0a2505b57e0f1.tar.bz2
pluralconnect-83354b2b88218090988dd6e526b0a2505b57e0f1.zip
Updated 5 files and added 1110 files (automated)
Diffstat (limited to 'includes/external/addressbook/node_modules/css-select/lib/esm/attributes.js')
-rw-r--r--includes/external/addressbook/node_modules/css-select/lib/esm/attributes.js222
1 files changed, 222 insertions, 0 deletions
diff --git a/includes/external/addressbook/node_modules/css-select/lib/esm/attributes.js b/includes/external/addressbook/node_modules/css-select/lib/esm/attributes.js
new file mode 100644
index 0000000..199467e
--- /dev/null
+++ b/includes/external/addressbook/node_modules/css-select/lib/esm/attributes.js
@@ -0,0 +1,222 @@
+import boolbase from "boolbase";
+/**
+ * All reserved characters in a regex, used for escaping.
+ *
+ * Taken from XRegExp, (c) 2007-2020 Steven Levithan under the MIT license
+ * https://github.com/slevithan/xregexp/blob/95eeebeb8fac8754d54eafe2b4743661ac1cf028/src/xregexp.js#L794
+ */
+const reChars = /[-[\]{}()*+?.,\\^$|#\s]/g;
+function escapeRegex(value) {
+ return value.replace(reChars, "\\$&");
+}
+/**
+ * Attributes that are case-insensitive in HTML.
+ *
+ * @private
+ * @see https://html.spec.whatwg.org/multipage/semantics-other.html#case-sensitivity-of-selectors
+ */
+const 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",
+]);
+function shouldIgnoreCase(selector, options) {
+ return typeof selector.ignoreCase === "boolean"
+ ? selector.ignoreCase
+ : selector.ignoreCase === "quirks"
+ ? !!options.quirksMode
+ : !options.xmlMode && caseInsensitiveAttributes.has(selector.name);
+}
+/**
+ * Attribute selectors
+ */
+export const attributeRules = {
+ equals(next, data, options) {
+ const { adapter } = options;
+ const { name } = data;
+ let { value } = data;
+ if (shouldIgnoreCase(data, options)) {
+ value = value.toLowerCase();
+ return (elem) => {
+ const attr = adapter.getAttributeValue(elem, name);
+ return (attr != null &&
+ attr.length === value.length &&
+ attr.toLowerCase() === value &&
+ next(elem));
+ };
+ }
+ return (elem) => adapter.getAttributeValue(elem, name) === value && next(elem);
+ },
+ hyphen(next, data, options) {
+ const { adapter } = options;
+ const { name } = data;
+ let { value } = data;
+ const len = value.length;
+ if (shouldIgnoreCase(data, options)) {
+ value = value.toLowerCase();
+ return function hyphenIC(elem) {
+ const attr = adapter.getAttributeValue(elem, name);
+ return (attr != null &&
+ (attr.length === len || attr.charAt(len) === "-") &&
+ attr.substr(0, len).toLowerCase() === value &&
+ next(elem));
+ };
+ }
+ return function hyphen(elem) {
+ const attr = adapter.getAttributeValue(elem, name);
+ return (attr != null &&
+ (attr.length === len || attr.charAt(len) === "-") &&
+ attr.substr(0, len) === value &&
+ next(elem));
+ };
+ },
+ element(next, data, options) {
+ const { adapter } = options;
+ const { name, value } = data;
+ if (/\s/.test(value)) {
+ return boolbase.falseFunc;
+ }
+ const regex = new RegExp(`(?:^|\\s)${escapeRegex(value)}(?:$|\\s)`, shouldIgnoreCase(data, options) ? "i" : "");
+ return function element(elem) {
+ const attr = adapter.getAttributeValue(elem, name);
+ return (attr != null &&
+ attr.length >= value.length &&
+ regex.test(attr) &&
+ next(elem));
+ };
+ },
+ exists(next, { name }, { adapter }) {
+ return (elem) => adapter.hasAttrib(elem, name) && next(elem);
+ },
+ start(next, data, options) {
+ const { adapter } = options;
+ const { name } = data;
+ let { value } = data;
+ const len = value.length;
+ if (len === 0) {
+ return boolbase.falseFunc;
+ }
+ if (shouldIgnoreCase(data, options)) {
+ value = value.toLowerCase();
+ return (elem) => {
+ const attr = adapter.getAttributeValue(elem, name);
+ return (attr != null &&
+ attr.length >= len &&
+ attr.substr(0, len).toLowerCase() === value &&
+ next(elem));
+ };
+ }
+ return (elem) => {
+ var _a;
+ return !!((_a = adapter.getAttributeValue(elem, name)) === null || _a === void 0 ? void 0 : _a.startsWith(value)) &&
+ next(elem);
+ };
+ },
+ end(next, data, options) {
+ const { adapter } = options;
+ const { name } = data;
+ let { value } = data;
+ const len = -value.length;
+ if (len === 0) {
+ return boolbase.falseFunc;
+ }
+ if (shouldIgnoreCase(data, options)) {
+ value = value.toLowerCase();
+ return (elem) => {
+ var _a;
+ return ((_a = adapter
+ .getAttributeValue(elem, name)) === null || _a === void 0 ? void 0 : _a.substr(len).toLowerCase()) === value && next(elem);
+ };
+ }
+ return (elem) => {
+ var _a;
+ return !!((_a = adapter.getAttributeValue(elem, name)) === null || _a === void 0 ? void 0 : _a.endsWith(value)) &&
+ next(elem);
+ };
+ },
+ any(next, data, options) {
+ const { adapter } = options;
+ const { name, value } = data;
+ if (value === "") {
+ return boolbase.falseFunc;
+ }
+ if (shouldIgnoreCase(data, options)) {
+ const regex = new RegExp(escapeRegex(value), "i");
+ return function anyIC(elem) {
+ const attr = adapter.getAttributeValue(elem, name);
+ return (attr != null &&
+ attr.length >= value.length &&
+ regex.test(attr) &&
+ next(elem));
+ };
+ }
+ return (elem) => {
+ var _a;
+ return !!((_a = adapter.getAttributeValue(elem, name)) === null || _a === void 0 ? void 0 : _a.includes(value)) &&
+ next(elem);
+ };
+ },
+ not(next, data, options) {
+ const { adapter } = options;
+ const { name } = data;
+ let { value } = data;
+ if (value === "") {
+ return (elem) => !!adapter.getAttributeValue(elem, name) && next(elem);
+ }
+ else if (shouldIgnoreCase(data, options)) {
+ value = value.toLowerCase();
+ return (elem) => {
+ const attr = adapter.getAttributeValue(elem, name);
+ return ((attr == null ||
+ attr.length !== value.length ||
+ attr.toLowerCase() !== value) &&
+ next(elem));
+ };
+ }
+ return (elem) => adapter.getAttributeValue(elem, name) !== value && next(elem);
+ },
+};
+//# sourceMappingURL=attributes.js.map \ No newline at end of file