# shim-selected-options

> Tiny HTMLSelectElement#selectedOptions shim for IE

Latest version **1.0.1** (published 2019-01-30) · MIT license · 0 weekly downloads

## Install

```sh
npm install shim-selected-options
pnpm add shim-selected-options
yarn add shim-selected-options
bun add shim-selected-options
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2019-01-30 |
| First published | 2018-06-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 2.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Aleksey Shvayka |
| Maintainers | shvaikalesh |
| Keywords | select, multiple, selected-options, shim, polyfill, ie |

## Links

- npm: https://www.npmjs.com/package/shim-selected-options
- Repository: https://github.com/shvaikalesh/shim-selected-options
- Homepage: https://github.com/shvaikalesh/shim-selected-options#readme
- Issues: https://github.com/shvaikalesh/shim-selected-options/issues
- npm.io page: https://npm.io/package/shim-selected-options

## Alternatives

- [launchdarkly-js-client-sdk](https://npm.io/package/launchdarkly-js-client-sdk.md) — 2.5M weekly downloads
- [@elastic/elasticsearch](https://npm.io/package/@elastic/elasticsearch.md) — 2.1M weekly downloads
- [@c8y/client](https://npm.io/package/@c8y/client.md) — 15.3K weekly downloads
- [@signaldb/maverickjs](https://npm.io/package/@signaldb/maverickjs.md) — 1.7K weekly downloads
- [@bbc/http-transport-cache](https://npm.io/package/@bbc/http-transport-cache.md) — 1.2K weekly downloads

## Recent versions

- 1.0.1 (latest) — 2019-01-30
- 1.0.0 — 2018-06-28

## README

# shim-selected-options

Tiny `HTMLSelectElement#selectedOptions` shim for IE.

* [Can I use `selectedOptions`?](https://developer.mozilla.org/en-US/docs/Web/API/HTMLSelectElement/selectedOptions#Browser_compatibility)
* [WHATWG: HTML spec](https://html.spec.whatwg.org/multipage/form-elements.html#dom-select-selectedoptions)
* [More conformant shim with IE8 support](https://gist.github.com/brettz9/4212217)

## Up and running

Get the package from [npm](https://www.npmjs.com/package/shim-selected-options):

```sh
npm install shim-selected-options --save
```

And simply require the module:

```js
import "shim-selected-options"
```

Otherwise, plug it the old-fashioned way:

```html
<script src="https://unpkg.com/shim-selected-options" async></script>
```

## Caveats

While making spec-perfect shim is technically possible,
it requires observing DOM subtrees to implement [quirks of `HTMLCollection`](https://heycam.github.io/webidl/#LegacyUnenumerableNamedProperties),
not to mention emulating live collection. For most cases, this solution is fine.

* New object instead of [always the same](https://heycam.github.io/webidl/#SameObject)
* `NodeList` instead of `HTMLCollection` instance
* Static collection instead of live

See more on collections in [WHATWG DOM spec](https://dom.spec.whatwg.org/#old-style-collections).

## Examples

Straightforward for single-value selects:

```diff
- let {text} = select.options[select.selectedIndex]
+ let [{text}] = select.selectedOptions
```

Precise typing for `multiple` selects:

```diff
- let opts = select.querySelectorAll(":checked") // NodeList<Element>
+ let opts = select.selectedOptions // HTMLCollection<HTMLSelectElement>
```

---
_Source: https://npm.io/package/shim-selected-options · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
