├── .npmrc ├── funding.yml ├── .prettierignore ├── .gitignore ├── .editorconfig ├── tsconfig.json ├── .github └── workflows │ └── main.yml ├── test.js ├── license ├── index.js ├── package.json └── readme.md /.npmrc: -------------------------------------------------------------------------------- 1 | package-lock=false 2 | -------------------------------------------------------------------------------- /funding.yml: -------------------------------------------------------------------------------- 1 | github: wooorm 2 | -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | coverage/ 2 | *.md 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | coverage/ 2 | node_modules/ 3 | *.d.ts 4 | *.log 5 | .DS_Store 6 | yarn.lock 7 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = space 5 | indent_size = 2 6 | end_of_line = lf 7 | charset = utf-8 8 | trim_trailing_whitespace = true 9 | insert_final_newline = true 10 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "include": ["**/**.js"], 3 | "exclude": ["coverage", "node_modules"], 4 | "compilerOptions": { 5 | "checkJs": true, 6 | "declaration": true, 7 | "emitDeclarationOnly": true, 8 | "exactOptionalPropertyTypes": true, 9 | "forceConsistentCasingInFileNames": true, 10 | "lib": ["es2020"], 11 | "module": "node16", 12 | "newLine": "lf", 13 | "skipLibCheck": true, 14 | "strict": true, 15 | "target": "es2020" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: main 2 | on: 3 | - pull_request 4 | - push 5 | jobs: 6 | main: 7 | name: ${{matrix.node}} 8 | runs-on: ubuntu-latest 9 | steps: 10 | - uses: actions/checkout@v3 11 | - uses: actions/setup-node@v3 12 | with: 13 | node-version: ${{matrix.node}} 14 | - run: npm install 15 | - run: npm test 16 | - uses: codecov/codecov-action@v3 17 | strategy: 18 | matrix: 19 | node: 20 | - lts/hydrogen 21 | - node 22 | -------------------------------------------------------------------------------- /test.js: -------------------------------------------------------------------------------- 1 | import assert from 'node:assert/strict' 2 | import test from 'node:test' 3 | import {htmlEventAttributes} from './index.js' 4 | 5 | test('htmlEventAttributes', function () { 6 | assert.ok(Array.isArray(htmlEventAttributes), 'should be an array') 7 | 8 | let index = -1 9 | while (++index < htmlEventAttributes.length) { 10 | const prop = htmlEventAttributes[index] 11 | assert.equal(typeof prop, 'string', prop + ' should be string') 12 | assert.strictEqual(prop, prop.trim(), prop + ' should be trimmed') 13 | assert.ok(/^on[a-z]+$/.test(prop), prop + ' should be `a-z`') 14 | } 15 | }) 16 | -------------------------------------------------------------------------------- /license: -------------------------------------------------------------------------------- 1 | (The MIT License) 2 | 3 | Copyright (c) 2019 Titus Wormer 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining 6 | a copy of this software and associated documentation files (the 7 | 'Software'), to deal in the Software without restriction, including 8 | without limitation the rights to use, copy, modify, merge, publish, 9 | distribute, sublicense, and/or sell copies of the Software, and to 10 | permit persons to whom the Software is furnished to do so, subject to 11 | the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 20 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 21 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 22 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * List of HTML event handler attributes. 3 | * 4 | * @type {Array} 5 | */ 6 | export const htmlEventAttributes = [ 7 | 'onabort', 8 | 'onafterprint', 9 | 'onauxclick', 10 | 'onbeforematch', 11 | 'onbeforeprint', 12 | 'onbeforetoggle', 13 | 'onbeforeunload', 14 | 'onblur', 15 | 'oncancel', 16 | 'oncanplay', 17 | 'oncanplaythrough', 18 | 'onchange', 19 | 'onclick', 20 | 'onclose', 21 | 'oncontextlost', 22 | 'oncontextmenu', 23 | 'oncontextrestored', 24 | 'oncopy', 25 | 'oncuechange', 26 | 'oncut', 27 | 'ondblclick', 28 | 'ondrag', 29 | 'ondragend', 30 | 'ondragenter', 31 | 'ondragleave', 32 | 'ondragover', 33 | 'ondragstart', 34 | 'ondrop', 35 | 'ondurationchange', 36 | 'onemptied', 37 | 'onended', 38 | 'onerror', 39 | 'onfocus', 40 | 'onformdata', 41 | 'onhashchange', 42 | 'oninput', 43 | 'oninvalid', 44 | 'onkeydown', 45 | 'onkeypress', 46 | 'onkeyup', 47 | 'onlanguagechange', 48 | 'onload', 49 | 'onloadeddata', 50 | 'onloadedmetadata', 51 | 'onloadstart', 52 | 'onmessage', 53 | 'onmessageerror', 54 | 'onmousedown', 55 | 'onmouseenter', 56 | 'onmouseleave', 57 | 'onmousemove', 58 | 'onmouseout', 59 | 'onmouseover', 60 | 'onmouseup', 61 | 'onoffline', 62 | 'ononline', 63 | 'onpagehide', 64 | 'onpageshow', 65 | 'onpaste', 66 | 'onpause', 67 | 'onplay', 68 | 'onplaying', 69 | 'onpopstate', 70 | 'onprogress', 71 | 'onratechange', 72 | 'onrejectionhandled', 73 | 'onreset', 74 | 'onresize', 75 | 'onscroll', 76 | 'onscrollend', 77 | 'onsecuritypolicyviolation', 78 | 'onseeked', 79 | 'onseeking', 80 | 'onselect', 81 | 'onslotchange', 82 | 'onstalled', 83 | 'onstorage', 84 | 'onsubmit', 85 | 'onsuspend', 86 | 'ontimeupdate', 87 | 'ontoggle', 88 | 'onunhandledrejection', 89 | 'onunload', 90 | 'onvolumechange', 91 | 'onwaiting', 92 | 'onwheel' 93 | ] 94 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "html-event-attributes", 3 | "version": "2.2.0", 4 | "description": "List of HTML event handler attributes", 5 | "license": "MIT", 6 | "keywords": [ 7 | "html", 8 | "event", 9 | "handler", 10 | "tag", 11 | "name", 12 | "attribute", 13 | "property", 14 | "w3c", 15 | "whatwg" 16 | ], 17 | "repository": "wooorm/html-event-attributes", 18 | "bugs": "https://github.com/wooorm/html-event-attributes/issues", 19 | "funding": { 20 | "type": "github", 21 | "url": "https://github.com/sponsors/wooorm" 22 | }, 23 | "author": "Titus Wormer (https://wooorm.com)", 24 | "contributors": [ 25 | "Titus Wormer (https://wooorm.com)" 26 | ], 27 | "sideEffects": false, 28 | "type": "module", 29 | "main": "index.js", 30 | "types": "index.d.ts", 31 | "files": [ 32 | "index.d.ts", 33 | "index.js" 34 | ], 35 | "devDependencies": { 36 | "@types/node": "^20.0.0", 37 | "alpha-sort": "^5.0.0", 38 | "c8": "^8.0.0", 39 | "hast-util-from-html": "^2.0.0", 40 | "hast-util-is-event-handler": "^3.0.0", 41 | "hast-util-select": "^6.0.0", 42 | "hast-util-to-string": "^3.0.0", 43 | "node-fetch": "^3.0.0", 44 | "prettier": "^3.0.0", 45 | "remark-cli": "^11.0.0", 46 | "remark-preset-wooorm": "^9.0.0", 47 | "type-coverage": "^2.0.0", 48 | "typescript": "^5.0.0", 49 | "xo": "^0.56.0" 50 | }, 51 | "scripts": { 52 | "prepack": "npm run build && npm run format", 53 | "generate": "node --conditions development build.js", 54 | "build": "tsc --build --clean && tsc --build && type-coverage", 55 | "format": "remark . -qfo && prettier . -w --log-level warn && xo --fix", 56 | "test-api": "node --conditions development test.js", 57 | "test-coverage": "c8 --check-coverage --100 --reporter lcov npm run test-api", 58 | "test": "npm run generate && npm run build && npm run format && npm run test-coverage" 59 | }, 60 | "prettier": { 61 | "tabWidth": 2, 62 | "useTabs": false, 63 | "singleQuote": true, 64 | "bracketSpacing": false, 65 | "semi": false, 66 | "trailingComma": "none" 67 | }, 68 | "xo": { 69 | "prettier": true 70 | }, 71 | "remarkConfig": { 72 | "plugins": [ 73 | "preset-wooorm" 74 | ] 75 | }, 76 | "typeCoverage": { 77 | "atLeast": 100, 78 | "detail": true, 79 | "strict": true, 80 | "ignoreCatch": true 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # html-event-attributes 2 | 3 | [![Build][build-badge]][build] 4 | [![Coverage][coverage-badge]][coverage] 5 | [![Downloads][downloads-badge]][downloads] 6 | [![Size][size-badge]][size] 7 | 8 | List of HTML event handler attributes. 9 | 10 | ## Contents 11 | 12 | * [What is this?](#what-is-this) 13 | * [When should I use this?](#when-should-i-use-this) 14 | * [Install](#install) 15 | * [Use](#use) 16 | * [API](#api) 17 | * [`htmlEventAttributes`](#htmleventattributes) 18 | * [Types](#types) 19 | * [Compatibility](#compatibility) 20 | * [Security](#security) 21 | * [Related](#related) 22 | * [Contribute](#contribute) 23 | * [License](#license) 24 | 25 | ## What is this? 26 | 27 | This is a list of all HTML event handlers (`onclick`, etc). 28 | It includes events from [HTML 4][html4] and [HTML][] (the living standard). 29 | 30 | ## When should I use this? 31 | 32 | You can use this package if you want to figure out whether an HTML attribute is 33 | a known event handler. 34 | 35 | ## Install 36 | 37 | This package is [ESM only][esm]. 38 | In Node.js (version 14.14+, 16.0+), install with [npm][]: 39 | 40 | ```sh 41 | npm install html-event-attributes 42 | ``` 43 | 44 | In Deno with [`esm.sh`][esmsh]: 45 | 46 | ```js 47 | import {htmlEventAttributes} from 'https://esm.sh/html-event-attributes@2' 48 | ``` 49 | 50 | In browsers with [`esm.sh`][esmsh]: 51 | 52 | ```html 53 | 56 | ``` 57 | 58 | ## Use 59 | 60 | ```js 61 | import {htmlEventAttributes} from 'html-event-attributes' 62 | 63 | console.log(htmlEventAttributes.slice(0, 10)) 64 | ``` 65 | 66 | Yields: 67 | 68 | ```js 69 | [ 70 | 'onabort', 71 | 'onafterprint', 72 | 'onauxclick', 73 | 'onbeforeprint', 74 | 'onbeforeunload', 75 | 'onblur', 76 | 'oncancel', 77 | 'oncanplay', 78 | 'oncanplaythrough', 79 | 'onchange' 80 | ] 81 | ``` 82 | 83 | ## API 84 | 85 | This package exports the identifier `htmlEventAttributes`. 86 | There is no default export. 87 | 88 | ### `htmlEventAttributes` 89 | 90 | List of HTML event handler attributes (`Array`). 91 | 92 | ## Types 93 | 94 | This package is fully typed with [TypeScript][]. 95 | It exports no additional types. 96 | 97 | ## Compatibility 98 | 99 | This package is at least compatible with all maintained versions of Node.js. 100 | As of now, that is Node.js 14.14+ and 16.0+. 101 | It also works in Deno and modern browsers. 102 | 103 | ## Security 104 | 105 | This package is safe. 106 | 107 | ## Related 108 | 109 | * [`wooorm/svg-event-attributes`](https://github.com/wooorm/svg-event-attributes) 110 | — list of SVG event attributes 111 | * [`wooorm/html-element-attributes`](https://github.com/wooorm/html-element-attributes) 112 | — map of HTML elements to attributes 113 | * [`wooorm/svg-element-attributes`](https://github.com/wooorm/svg-element-attributes) 114 | — map of SVG elements to attributes 115 | * [`wooorm/aria-attributes`](https://github.com/wooorm/aria-attributes) 116 | — list of ARIA attributes 117 | 118 | ## Contribute 119 | 120 | Yes please! 121 | See [How to Contribute to Open Source][contribute]. 122 | 123 | ## License 124 | 125 | [MIT][license] © [Titus Wormer][author] 126 | 127 | 128 | 129 | [build-badge]: https://github.com/wooorm/html-event-attributes/workflows/main/badge.svg 130 | 131 | [build]: https://github.com/wooorm/html-event-attributes/actions 132 | 133 | [coverage-badge]: https://img.shields.io/codecov/c/github/wooorm/html-event-attributes.svg 134 | 135 | [coverage]: https://codecov.io/github/wooorm/html-event-attributes 136 | 137 | [downloads-badge]: https://img.shields.io/npm/dm/html-event-attributes.svg 138 | 139 | [downloads]: https://www.npmjs.com/package/html-event-attributes 140 | 141 | [size-badge]: https://img.shields.io/bundlephobia/minzip/html-event-attributes.svg 142 | 143 | [size]: https://bundlephobia.com/result?p=html-event-attributes 144 | 145 | [npm]: https://docs.npmjs.com/cli/install 146 | 147 | [esmsh]: https://esm.sh 148 | 149 | [license]: license 150 | 151 | [author]: https://wooorm.com 152 | 153 | [esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c 154 | 155 | [typescript]: https://www.typescriptlang.org 156 | 157 | [contribute]: https://opensource.guide/how-to-contribute/ 158 | 159 | [html4]: https://www.w3.org/TR/html4/index/attributes.html 160 | 161 | [html]: https://html.spec.whatwg.org/multipage/indices.html 162 | --------------------------------------------------------------------------------