Skip to content

Commit 51ec858

Browse files
committed
[Fix] no-unknown-property: onError and onLoad both work on img and script
Fixes #3388
1 parent 8116891 commit 51ec858

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

CHANGELOG.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange
55

66
## Unreleased
77

8+
### Fixed
9+
* [`no-unknown-property`]: `onError` and `onLoad` both work on `img` and `script` ([#3388][] @ljharb)
10+
11+
[#3388]: https://github.com/jsx-eslint/eslint-plugin-react/issues/3388
12+
813
## [7.31.5] - 2022.09.03
914

1015
### Fixed
@@ -14,7 +19,7 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange
1419
* [`no-unknown-property`]: `children` is always an acceptable prop; iframes have `scrolling`; video has `playsInline` ([#3385][] @ljharb)
1520

1621
[7.31.5]: https://github.com/jsx-eslint/eslint-plugin-react/compare/v7.31.4...v7.31.5
17-
[#3385]: https://github.com/jsx-eslint/eslint-plugin-react/issues/3385
22+
[#3385]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3385
1823

1924
## [7.31.4] - 2022.09.03
2025

lib/rules/no-unknown-property.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ const ATTRIBUTE_TAGS_MAP = {
6363
onEmptied: ['audio', 'video'],
6464
onEncrypted: ['audio', 'video'],
6565
onEnded: ['audio', 'video'],
66-
onError: ['audio', 'video'],
66+
onError: ['audio', 'video', 'img', 'script'],
67+
onLoad: ['script', 'img'],
6768
onLoadedData: ['audio', 'video'],
6869
onLoadedMetadata: ['audio', 'video'],
6970
onLoadStart: ['audio', 'video'],

tests/lib/rules/no-unknown-property.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ ruleTester.run('no-unknown-property', rule, {
5757
{ code: '<meta property="og:type" content="website" />' },
5858
{ code: '<input type="checkbox" checked={checked} disabled={disabled} id={id} onChange={onChange} />' },
5959
{ code: '<video playsInline />' },
60+
{ code: '<img onError={foo} onLoad={bar} />' },
61+
{ code: '<script onLoad={bar} onError={foo} />' },
6062
{
6163
code: '<div allowTransparency="true" />',
6264
settings: {
@@ -383,7 +385,7 @@ ruleTester.run('no-unknown-property', rule, {
383385
data: {
384386
name: 'onError',
385387
tagName: 'div',
386-
allowedTags: 'audio, video',
388+
allowedTags: 'audio, video, img, script',
387389
},
388390
},
389391
],

0 commit comments

Comments
 (0)