summaryrefslogtreecommitdiff
path: root/includes/external/addressbook/node_modules/domutils/lib/esm/traversal.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/domutils/lib/esm/traversal.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/domutils/lib/esm/traversal.js')
-rw-r--r--includes/external/addressbook/node_modules/domutils/lib/esm/traversal.js110
1 files changed, 110 insertions, 0 deletions
diff --git a/includes/external/addressbook/node_modules/domutils/lib/esm/traversal.js b/includes/external/addressbook/node_modules/domutils/lib/esm/traversal.js
new file mode 100644
index 0000000..71dddd7
--- /dev/null
+++ b/includes/external/addressbook/node_modules/domutils/lib/esm/traversal.js
@@ -0,0 +1,110 @@
+import { isTag, hasChildren, } from "domhandler";
+/**
+ * Get a node's children.
+ *
+ * @category Traversal
+ * @param elem Node to get the children of.
+ * @returns `elem`'s children, or an empty array.
+ */
+export function getChildren(elem) {
+ return hasChildren(elem) ? elem.children : [];
+}
+/**
+ * Get a node's parent.
+ *
+ * @category Traversal
+ * @param elem Node to get the parent of.
+ * @returns `elem`'s parent node.
+ */
+export function getParent(elem) {
+ return elem.parent || null;
+}
+/**
+ * Gets an elements siblings, including the element itself.
+ *
+ * Attempts to get the children through the element's parent first. If we don't
+ * have a parent (the element is a root node), we walk the element's `prev` &
+ * `next` to get all remaining nodes.
+ *
+ * @category Traversal
+ * @param elem Element to get the siblings of.
+ * @returns `elem`'s siblings.
+ */
+export function getSiblings(elem) {
+ const parent = getParent(elem);
+ if (parent != null)
+ return getChildren(parent);
+ const siblings = [elem];
+ let { prev, next } = elem;
+ while (prev != null) {
+ siblings.unshift(prev);
+ ({ prev } = prev);
+ }
+ while (next != null) {
+ siblings.push(next);
+ ({ next } = next);
+ }
+ return siblings;
+}
+/**
+ * Gets an attribute from an element.
+ *
+ * @category Traversal
+ * @param elem Element to check.
+ * @param name Attribute name to retrieve.
+ * @returns The element's attribute value, or `undefined`.
+ */
+export function getAttributeValue(elem, name) {
+ var _a;
+ return (_a = elem.attribs) === null || _a === void 0 ? void 0 : _a[name];
+}
+/**
+ * Checks whether an element has an attribute.
+ *
+ * @category Traversal
+ * @param elem Element to check.
+ * @param name Attribute name to look for.
+ * @returns Returns whether `elem` has the attribute `name`.
+ */
+export function hasAttrib(elem, name) {
+ return (elem.attribs != null &&
+ Object.prototype.hasOwnProperty.call(elem.attribs, name) &&
+ elem.attribs[name] != null);
+}
+/**
+ * Get the tag name of an element.
+ *
+ * @category Traversal
+ * @param elem The element to get the name for.
+ * @returns The tag name of `elem`.
+ */
+export function getName(elem) {
+ return elem.name;
+}
+/**
+ * Returns the next element sibling of a node.
+ *
+ * @category Traversal
+ * @param elem The element to get the next sibling of.
+ * @returns `elem`'s next sibling that is a tag.
+ */
+export function nextElementSibling(elem) {
+ let { next } = elem;
+ while (next !== null && !isTag(next))
+ ({ next } = next);
+ return next;
+}
+/**
+ * Returns the previous element sibling of a node.
+ *
+ * @category Traversal
+ * @param elem The element to get the previous sibling of.
+ * @returns `elem`'s previous sibling that is a tag.
+ */
+export function prevElementSibling(elem) {
+ let { prev } = elem;
+ while (prev !== null && !isTag(prev))
+ ({ prev } = prev);
+ return prev;
+}
+//# sourceMappingURL=traversal.js.map \ No newline at end of file