select-dom
Advanced tools
Comparing version 9.0.1 to 9.1.0
{ | ||
"name": "select-dom", | ||
"version": "9.0.1", | ||
"version": "9.1.0", | ||
"description": "Extra lightweight DOM selector helper", | ||
@@ -20,3 +20,6 @@ "keywords": [ | ||
"type": "module", | ||
"exports": "./index.js", | ||
"exports": { | ||
".": "./index.js", | ||
"./strict.js": "./strict.js" | ||
}, | ||
"main": "./index.js", | ||
@@ -23,0 +26,0 @@ "types": "./index.d.ts", |
@@ -9,4 +9,2 @@ # select-dom [![][badge-gzip]][link-npm] [![npm downloads][badge-downloads]][link-npm] | ||
Version 7+ only supports browsers with [iterable `NodeList`s](https://developer.mozilla.org/en-US/docs/Web/API/NodeList/entries). If you need IE support, stick to [`select-dom@6`](https://github.com/fregante/select-dom/tree/v6.0.4) or lower. | ||
## Install | ||
@@ -19,4 +17,6 @@ | ||
```js | ||
// This module is only offered as a ES Module | ||
import {$, $$, lastElement, elementExists} from 'select-dom'; | ||
// And a stricter version | ||
import {$, $optional} from 'select-dom/strict.js'; | ||
``` | ||
@@ -31,3 +31,2 @@ | ||
Maps to `baseElement.querySelector(selector)`, except it returns `undefined` if it's not found | ||
```js | ||
@@ -79,2 +78,13 @@ $('.foo a[href=bar]'); | ||
## /strict.js | ||
The strict export will throw an error if the element is not found, instead of returning `undefined`. This is also reflected in the types, which are non-nullable: | ||
```ts | ||
import {$, $optional} from 'select-dom/strict.js'; | ||
const must: HTMLAnchorElement = $('.foo a[href=bar]'); // | ||
const optional: HTMLAnchorElement | undefined = $optional('.foo a[href=bar]'); | ||
``` | ||
## Related | ||
@@ -81,0 +91,0 @@ |
10201
90