Skip to main content
Glama
element-utils.js1.98 kB
import { TOOLBAR_CONTAINER_CLASS, TOOLBAR_ID } from '../constants'; export function isElementInToolbar(el) { var _a; if (el instanceof Element) { // closest isn't available in IE11, but we'll polyfill when bundling return el.id === TOOLBAR_ID || !!((_a = el.closest) === null || _a === void 0 ? void 0 : _a.call(el, '.' + TOOLBAR_CONTAINER_CLASS)); } return false; } /* * Check whether an element has nodeType Node.ELEMENT_NODE * @param {Element} el - element to check * @returns {boolean} whether el is of the correct nodeType */ export function isElementNode(el) { return !!el && el.nodeType === 1; // Node.ELEMENT_NODE - use integer constant for browser portability } /* * Check whether an element is of a given tag type. * Due to potential reference discrepancies (such as the webcomponents.js polyfill), * we want to match tagNames instead of specific references because something like * element === document.body won't always work because element might not be a native * element. * @param {Element} el - element to check * @param {string} tag - tag name (e.g., "div") * @returns {boolean} whether el is of the given tag type */ export function isTag(el, tag) { return !!el && !!el.tagName && el.tagName.toLowerCase() === tag.toLowerCase(); } /* * Check whether an element has nodeType Node.TEXT_NODE * @param {Element} el - element to check * @returns {boolean} whether el is of the correct nodeType */ export function isTextNode(el) { return !!el && el.nodeType === 3; // Node.TEXT_NODE - use integer constant for browser portability } /* * Check whether an element has nodeType Node.DOCUMENT_FRAGMENT_NODE * @param {Element} el - element to check * @returns {boolean} whether el is of the correct nodeType */ export function isDocumentFragment(el) { return !!el && el.nodeType === 11; // Node.DOCUMENT_FRAGMENT_NODE - use integer constant for browser portability } //# sourceMappingURL=element-utils.js.map

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/sadiuysal/mem0-mcp-server-ts'

If you have feedback or need assistance with the MCP directory API, please join our Discord server