@web3r/flowerkit
Version:
Tree-shakable JavaScript and TypeScript utility library for frontend/browser apps: DOM, events, arrays, objects, strings, date, JSON, and network helpers (ESM/CJS, SSR-friendly).
1 lines • 1.11 kB
Source Map (JSON)
{"version":3,"file":"index.cjs","sources":[""],"sourcesContent":["export type TIsNodeArgs = Parameters<typeof isNode>;\r\n\r\nexport type TIsNodeReturn = ReturnType<typeof isNode>;\r\n\r\n/**\r\n * Checks whether the specified object is a DOM element\r\n * @param el{any} source object\r\n * @returns {boolean}\r\n * @example\r\n * // How to check if an object is dom node?\r\n * const isMyElNode = isNode(document.getElementById(\"test\"));\r\n * console.log(isMyElNode) // => boolean\r\n */\r\nexport const isNode = (el: any): boolean => {\r\n if (typeof Element === \"undefined\" || typeof Document === \"undefined\") {\r\n return typeof el === \"object\" && el.nodeType === 1 && typeof el.style === \"object\" && typeof el.ownerDocument === \"object\";\r\n } else {\r\n return el instanceof Element || el instanceof Document;\r\n }\r\n};\r\n"],"names":["isNode","el","Element","Document","nodeType","style","ownerDocument"],"mappings":";;;;;;;;;GAaO,MAAMA,OAAUC,KACrB,UAAWC,UAAY,oBAAsBC,WAAa,YACxD,cAAcF,KAAO,UAAYA,GAAGG,WAAa,UAAYH,GAAGI,QAAU,iBAAmBJ,GAAGK,gBAAkB,cAElH,OAAOL,cAAcC,SAAWD,cAAcE"}