Skip to content
This repository was archived by the owner on Aug 9, 2023. It is now read-only.

Commit 6b01ccd

Browse files
committed
Mark hast-util-menu-state as legacy
1 parent 5b71e47 commit 6b01ccd

File tree

2 files changed

+8
-214
lines changed

2 files changed

+8
-214
lines changed

package.json

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,9 @@
11
{
22
"name": "hast-util-menu-state",
33
"version": "2.0.2",
4-
"description": "hast utility to get the state of a menu element",
4+
"description": "Legacy hast utility to get the state of a menu element — menu states were removed from HTML",
55
"license": "MIT",
6-
"keywords": [
7-
"unist",
8-
"hast",
9-
"hast-util",
10-
"util",
11-
"utility",
12-
"html",
13-
"element",
14-
"menu",
15-
"state",
16-
"context",
17-
"toolbar"
18-
],
6+
"keywords": [],
197
"repository": "syntax-tree/hast-util-menu-state",
208
"bugs": "https://github.com/syntax-tree/hast-util-menu-state/issues",
219
"funding": {

readme.md

Lines changed: 6 additions & 200 deletions
Original file line numberDiff line numberDiff line change
@@ -1,212 +1,18 @@
11
# hast-util-menu-state
22

3-
[![Build][build-badge]][build]
4-
[![Coverage][coverage-badge]][coverage]
5-
[![Downloads][downloads-badge]][downloads]
6-
[![Size][size-badge]][size]
7-
[![Sponsors][sponsors-badge]][collective]
8-
[![Backers][backers-badge]][collective]
9-
[![Chat][chat-badge]][chat]
3+
**Stability: Legacy**.
4+
This package is no longer recommended for use.
5+
Menu states are removed from the [HTML spec][spec]
106

11-
[hast][] utility to get the [*state*][spec] of a `<menu>` element.
12-
13-
## Contents
14-
15-
* [What is this?](#what-is-this)
16-
* [When should I use this?](#when-should-i-use-this)
17-
* [Install](#install)
18-
* [Use](#use)
19-
* [API](#api)
20-
* [`menuState(nodes)`](#menustatenodes)
21-
* [`MenuState`](#menustate)
22-
* [Types](#types)
23-
* [Compatibility](#compatibility)
24-
* [Security](#security)
25-
* [Related](#related)
26-
* [Contribute](#contribute)
27-
* [License](#license)
28-
29-
## What is this?
30-
31-
This package is a small utility that get the menu state according to HTML.
32-
33-
## When should I use this?
34-
35-
This utility is super niche, if you’re here you probably know what you’re
36-
looking for!
37-
38-
## Install
39-
40-
This package is [ESM only][esm].
41-
In Node.js (version 14.14+ and 16.0+), install with [npm][]:
42-
43-
```sh
44-
npm install hast-util-menu-state
45-
```
46-
47-
In Deno with [`esm.sh`][esmsh]:
48-
49-
```js
50-
import {menuState} from 'https://esm.sh/hast-util-menu-state@2'
51-
```
52-
53-
In browsers with [`esm.sh`][esmsh]:
54-
55-
```html
56-
<script type="module">
57-
import {menuState} from 'https://esm.sh/hast-util-menu-state@2?bundle'
58-
</script>
59-
```
60-
61-
## Use
62-
63-
```js
64-
import {menuState} from 'hast-util-menu-state'
65-
66-
// If there’s no last element or that node is not a `menu`:
67-
menuState([{type: 'element', tagName: 'a'}]) // => null
68-
69-
// If the last node is a `menu` without `type`:
70-
menuState([{type: 'element', tagName: 'menu'}]) // => 'toolbar'
71-
72-
// If the last node is a `menu` with a `type`, or that node has
73-
// a parent `menu` with a type:
74-
menuState([
75-
{type: 'element', tagName: 'menu', properties: {type: 'context'}},
76-
{type: 'element', tagName: 'li'},
77-
{type: 'element', tagName: 'menu'}
78-
]) // => 'context'
79-
```
80-
81-
## API
82-
83-
This package exports the identifier [`menuState`][menustate].
84-
There is no default export.
85-
86-
### `menuState(nodes)`
87-
88-
Get the [*state*][spec] of a `<menu>` element.
89-
90-
The state is calculated from the lowest `<menu>` with a valid `type` property.
91-
If no `<menu>` has a `type`, it defaults to `'toolbar'`.
92-
93-
The algorithm stops looking for higher `<menu>`s if a `template` element, or
94-
non-element, is found.
95-
96-
###### Parameters
97-
98-
* `nodes` ([`Array<Node>`][node], optional)
99-
— nodes to check, where the last node should be a `<menu>` element,
100-
the first node must be its root, and all nodes are therefore inclusive
101-
ancestors
102-
103-
###### Returns
104-
105-
The state the `menu` is in ([`MenuState`][menustate-type]), or `null` if the
106-
last node is not a `menu` element.
107-
108-
### `MenuState`
109-
110-
The state a `menu` is in (TypeScript type).
111-
112-
###### Type
113-
114-
```ts
115-
type MenuState = 'context' | 'toolbar'
116-
```
117-
118-
## Types
119-
120-
This package is fully typed with [TypeScript][].
121-
It exports the additional type [`MenuState`][menustate-type].
122-
123-
## Compatibility
124-
125-
Projects maintained by the unified collective are compatible with all maintained
126-
versions of Node.js.
127-
As of now, that is Node.js 14.14+ and 16.0+.
128-
Our projects sometimes work with older versions, but this is not guaranteed.
129-
130-
## Security
131-
132-
`hast-util-menu-state` does not change the syntax tree so there are no openings
133-
for [cross-site scripting (XSS)][xss] attacks.
134-
135-
## Related
136-
137-
* [`unist-util-visit-parents`](https://github.com/syntax-tree/unist-util-visit-parents)
138-
— recursively walk over unist nodes, with ancestral information
139-
140-
## Contribute
141-
142-
See [`contributing.md`][contributing] in [`syntax-tree/.github`][health] for
143-
ways to get started.
144-
See [`support.md`][support] for ways to get help.
145-
146-
This project has a [code of conduct][coc].
147-
By interacting with this repository, organization, or community you agree to
148-
abide by its terms.
7+
Legacy [documentation for this package](https://github.com/syntax-tree/hast-util-menu-state/tree/5b71e472e3bc4696ecda282f0900a486d95880d8)
8+
is still available in Git.
1499

15010
## License
15111

15212
[MIT][license] © [Titus Wormer][author]
15313

154-
<!-- Definition -->
155-
156-
[build-badge]: https://github.com/syntax-tree/hast-util-menu-state/workflows/main/badge.svg
157-
158-
[build]: https://github.com/syntax-tree/hast-util-menu-state/actions
159-
160-
[coverage-badge]: https://img.shields.io/codecov/c/github/syntax-tree/hast-util-menu-state.svg
161-
162-
[coverage]: https://codecov.io/github/syntax-tree/hast-util-menu-state
163-
164-
[downloads-badge]: https://img.shields.io/npm/dm/hast-util-menu-state.svg
165-
166-
[downloads]: https://www.npmjs.com/package/hast-util-menu-state
167-
168-
[size-badge]: https://img.shields.io/bundlephobia/minzip/hast-util-menu-state.svg
169-
170-
[size]: https://bundlephobia.com/result?p=hast-util-menu-state
171-
172-
[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg
173-
174-
[backers-badge]: https://opencollective.com/unified/backers/badge.svg
175-
176-
[collective]: https://opencollective.com/unified
177-
178-
[chat-badge]: https://img.shields.io/badge/chat-discussions-success.svg
179-
180-
[chat]: https://github.com/syntax-tree/unist/discussions
181-
182-
[npm]: https://docs.npmjs.com/cli/install
183-
184-
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
185-
186-
[esmsh]: https://esm.sh
187-
188-
[typescript]: https://www.typescriptlang.org
14+
[spec]: https://html.spec.whatwg.org/multipage/obsolete.html#attr-menu-type
18915

19016
[license]: license
19117

19218
[author]: https://wooorm.com
193-
194-
[health]: https://github.com/syntax-tree/.github
195-
196-
[contributing]: https://github.com/syntax-tree/.github/blob/main/contributing.md
197-
198-
[support]: https://github.com/syntax-tree/.github/blob/main/support.md
199-
200-
[coc]: https://github.com/syntax-tree/.github/blob/main/code-of-conduct.md
201-
202-
[spec]: https://html.spec.whatwg.org/multipage/obsolete.html#attr-menu-type
203-
204-
[node]: https://github.com/syntax-tree/unist#node
205-
206-
[hast]: https://github.com/syntax-tree/hast
207-
208-
[xss]: https://en.wikipedia.org/wiki/Cross-site_scripting
209-
210-
[menustate]: #menustatenodes
211-
212-
[menustate-type]: #menustate

0 commit comments

Comments
 (0)