@acanto/core-dom
Advanced tools
Comparing version 0.0.15 to 0.0.16
12
index.ts
@@ -29,2 +29,3 @@ /** | ||
* @param {HTMLElement | Document} [parent] It falls back to `window.document` | ||
* @param {boolean} [avoidEscape] Whether to avoid escaping `:` in the selector string | ||
* @example <caption>Basic DOM selection</caption> | ||
@@ -36,6 +37,7 @@ * const $container = $(".my-section:"); | ||
selector: string, | ||
parent?: HTMLElement | Document | ||
parent?: HTMLElement | Document, | ||
avoidEscape?: boolean | ||
) { | ||
return ((parent ? parent : document).querySelector( | ||
selector.replace(/:/g, "\\:") | ||
avoidEscape ? selector : selector.replace(/:/g, "\\:") | ||
) as unknown) as T; | ||
@@ -50,9 +52,11 @@ } | ||
* @param {HTMLElement | Document} [parent] It falls back to `window.document` | ||
* @param {boolean} [avoidEscape] Whether to avoid escaping `:` in the selector string | ||
*/ | ||
export function $$<T extends Element = HTMLElement>( | ||
selector: string, | ||
parent?: HTMLElement | Document | ||
parent?: HTMLElement | Document, | ||
avoidEscape?: boolean | ||
) { | ||
return ((parent ? parent : document).querySelectorAll( | ||
selector.replace(/:/g, "\\:") | ||
avoidEscape ? selector : selector.replace(/:/g, "\\:") | ||
) as unknown) as NodeListOf<T>; | ||
@@ -59,0 +63,0 @@ } |
{ | ||
"name": "@acanto/core-dom", | ||
"version": "0.0.15", | ||
"version": "0.0.16", | ||
"author": "Acanto <info@acanto.net> (https://acanto.agency/)", | ||
@@ -18,3 +18,3 @@ "license": "ISC", | ||
"sideEffects": false, | ||
"gitHead": "7c45c0d8dcb33b3e5d87e0f4c27ef9087c10ed35" | ||
"gitHead": "d72bfa57c6debe42b34eb6eb81f22d0021297eaf" | ||
} |
23750
775