@design-edito/tools 0.1.37 → 0.1.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/agnostic/css/bem/index.js +2 -2
- package/agnostic/css/index.js +11 -11
- package/agnostic/errors/index.js +2 -2
- package/agnostic/html/hyper-json/cast/index.js +2 -2
- package/agnostic/html/hyper-json/index.js +3 -3
- package/agnostic/html/hyper-json/transformers/append/index.js +2 -2
- package/agnostic/html/hyper-json/transformers/classList/index.js +2 -2
- package/agnostic/html/hyper-json/transformers/index.js +2 -2
- package/agnostic/html/hyper-json/transformers/join/index.js +2 -2
- package/agnostic/html/hyper-json/transformers/length/index.js +2 -2
- package/agnostic/html/hyper-json/transformers/print/index.js +2 -2
- package/agnostic/html/hyper-json/transformers/push/index.js +2 -2
- package/agnostic/html/hyper-json/transformers/querySelector/index.js +2 -2
- package/agnostic/html/hyper-json/transformers/ref/index.js +2 -2
- package/agnostic/html/hyper-json/transformers/replace/index.js +2 -2
- package/agnostic/html/hyper-json/transformers/split/index.js +2 -2
- package/agnostic/html/hyper-json/transformers/toArray/index.js +2 -2
- package/agnostic/html/hyper-json/transformers/toBoolean/index.js +2 -2
- package/agnostic/html/hyper-json/transformers/toElement/index.js +2 -2
- package/agnostic/html/hyper-json/transformers/toNodeList/index.js +2 -2
- package/agnostic/html/hyper-json/transformers/toNull/index.js +2 -2
- package/agnostic/html/hyper-json/transformers/toNumber/index.js +2 -2
- package/agnostic/html/hyper-json/transformers/toRecord/index.js +2 -2
- package/agnostic/html/hyper-json/transformers/toRef/index.js +2 -2
- package/agnostic/html/hyper-json/transformers/toString/index.js +2 -2
- package/agnostic/html/hyper-json/transformers/toText/index.js +2 -2
- package/agnostic/html/hyper-json/transformers/toTransformer/index.js +2 -2
- package/agnostic/html/hyper-json/transformers/transformSelected/index.js +2 -2
- package/agnostic/html/hyper-json/transformers/trim/index.js +2 -2
- package/agnostic/html/hyper-json/tree/index.js +2 -2
- package/agnostic/html/hyper-json/utils/index.js +2 -2
- package/agnostic/html/index.js +20 -20
- package/agnostic/html/sanitize/index.js +6 -6
- package/agnostic/html/selector-to-element/index.js +6 -6
- package/agnostic/html/string-to-nodes/index.js +7 -7
- package/agnostic/misc/crossenv/index.js +2 -2
- package/agnostic/misc/elo/index.d.ts +31 -0
- package/agnostic/misc/elo/index.js +32 -0
- package/agnostic/misc/index.js +13 -13
- package/agnostic/misc/logs/index.js +2 -2
- package/agnostic/misc/logs/logger/index.d.ts +3 -0
- package/agnostic/misc/logs/logger/index.js +1 -1
- package/agnostic/misc/lorem-ipsum/index.js +5 -5
- package/agnostic/objects/index.js +3 -3
- package/agnostic/random/index.js +2 -2
- package/agnostic/regexps/index.d.ts +1 -0
- package/agnostic/regexps/index.js +1 -0
- package/agnostic/strings/index.js +7 -7
- package/agnostic/strings/replace-all/index.d.ts +1 -1
- package/agnostic/strings/replace-all/index.js +1 -1
- package/agnostic/time/index.js +3 -3
- package/chunks/chunk-6JRUZYTL.js +211 -0
- package/chunks/chunk-DCKTGQOX.js +29 -0
- package/chunks/chunk-GB4UQS6V.js +35 -0
- package/chunks/chunk-LOFELEU3.js +1108 -0
- package/chunks/chunk-LVXK54LL.js +27 -0
- package/chunks/chunk-MJQF3YZO.js +21 -0
- package/chunks/chunk-PPHUIOHO.js +28 -0
- package/chunks/chunk-QHGZBCFZ.js +1108 -0
- package/chunks/chunk-QN3UAKIU.js +21 -0
- package/chunks/chunk-RASMASS4.js +111 -0
- package/chunks/chunk-RHV7UOXD.js +211 -0
- package/chunks/chunk-S7MJLTCR.js +211 -0
- package/chunks/chunk-U6YRINXJ.js +22 -0
- package/chunks/chunk-YO5KOEJF.js +27 -0
- package/chunks/chunk-Z352MSRL.js +127 -0
- package/chunks/chunk-ZTDVUXPR.js +16 -0
- package/package.json +1 -1
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import {
|
|
2
|
+
register
|
|
3
|
+
} from "./chunk-U6YRINXJ.js";
|
|
4
|
+
|
|
5
|
+
// src/agnostic/html/selector-to-element/index.ts
|
|
6
|
+
function selectorToElement(selector, documentObj) {
|
|
7
|
+
const actualDocument = documentObj ?? window.document;
|
|
8
|
+
if (actualDocument === null) throw register.getError("no-window-document-on-runtime-please-provide" /* NO_DOCUMENT_PLEASE_PROVIDE */, "The optional second parameter expects a Document object");
|
|
9
|
+
const tagRegexp = /^[A-Za-z]+/;
|
|
10
|
+
const idRegexp = /#[A-Za-z]+[\w\-\:]*/;
|
|
11
|
+
const classRegexp = /\.[A-Za-z]+[\w\-]*/;
|
|
12
|
+
const attributeRegexp = /\[[A-Za-z]+[\w\-]*(="[\w\-]+")?\]/;
|
|
13
|
+
const matchedTags = selector.match(tagRegexp) ?? [];
|
|
14
|
+
const matchedIds = selector.match(idRegexp) ?? [];
|
|
15
|
+
const matchedClasses = selector.match(classRegexp) ?? [];
|
|
16
|
+
const matchedAttrs = selector.match(attributeRegexp) ?? [];
|
|
17
|
+
const tag = matchedTags[matchedTags.length - 1] ?? "div";
|
|
18
|
+
const id = matchedIds[matchedIds.length - 1] ?? null;
|
|
19
|
+
const classes = matchedClasses.map((matchedClass) => matchedClass.replace(/^\./, ""));
|
|
20
|
+
const attributes = matchedAttrs.map((matchedAttr) => matchedAttr.replace(/^\[/, "").replace(/\]$/, "").split("="));
|
|
21
|
+
const element = actualDocument.createElement(tag);
|
|
22
|
+
if (id !== null) {
|
|
23
|
+
element.id = id;
|
|
24
|
+
}
|
|
25
|
+
element.classList.add(...classes);
|
|
26
|
+
attributes.forEach(([name, value = ""]) => {
|
|
27
|
+
if (name === void 0) return;
|
|
28
|
+
element.setAttribute(name, value);
|
|
29
|
+
});
|
|
30
|
+
return element;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export {
|
|
34
|
+
selectorToElement
|
|
35
|
+
};
|