Skip to content

Commit

Permalink
[Fix] no-unknown-property: add onError and onLoad for iframe/picture
Browse files Browse the repository at this point in the history
Fixes #3410.

Co-authored-by: Emmanuel Vuigner <hi@maiis.me>
Co-authored-by: Aarni Koskela <akx@iki.fi>
  • Loading branch information
2 people authored and ljharb committed Sep 5, 2022
1 parent 1c0c92b commit 033fcc5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Expand Up @@ -12,8 +12,11 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange
* [`no-unknown-property`]: `controlsList`, not `controlList` ([#3397][] @ljharb)
* [`no-unknown-property`]: add more capture event properties ([#3402][] @sjarva)
* [`no-unknown-property`]: Add more one word properties found in DefinitelyTyped's react/index.d.ts ([#3402][] @sjarva)
* [`no-unknown-property`]: Mark onLoad/onError as supported on iframes ([#3398][] @maiis, [#3406][] @akx)

[#3406]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3406
[#3402]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3402
[#3398]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3398
[#3397]: https://github.com/jsx-eslint/eslint-plugin-react/issues/3397
[#3396]: https://github.com/jsx-eslint/eslint-plugin-react/issues/3396
[#3394]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3394
Expand Down
4 changes: 2 additions & 2 deletions lib/rules/no-unknown-property.js
Expand Up @@ -68,8 +68,8 @@ const ATTRIBUTE_TAGS_MAP = {
onEmptied: ['audio', 'video'],
onEncrypted: ['audio', 'video'],
onEnded: ['audio', 'video'],
onError: ['audio', 'video', 'img', 'link', 'source', 'script'],
onLoad: ['script', 'img', 'link'],
onError: ['audio', 'video', 'img', 'link', 'source', 'script', 'picture', 'iframe'],
onLoad: ['script', 'img', 'link', 'picture', 'iframe'],
onLoadedData: ['audio', 'video'],
onLoadedMetadata: ['audio', 'video'],
onLoadStart: ['audio', 'video'],
Expand Down
8 changes: 5 additions & 3 deletions tests/lib/rules/no-unknown-property.js
Expand Up @@ -50,7 +50,7 @@ ruleTester.run('no-unknown-property', rule, {
{ code: '<input type="password" required />' },
{ code: '<input ref={this.input} type="radio" />' },
{ code: '<div children="anything" />' },
{ code: '<iframe scrolling="?" />' },
{ code: '<iframe scrolling="?" onLoad={a} onError={b} />' },
{ code: '<input key="bar" type="radio" />' },
{ code: '<button disabled>You cannot click me</button>;' },
{ code: '<svg key="lock" viewBox="box" fill={10} d="d" stroke={1} strokeWidth={2} strokeLinecap={3} strokeLinejoin={4} transform="something" clipRule="else" x1={5} x2="6" y1="7" y2="8"></svg>' },
Expand All @@ -60,6 +60,8 @@ ruleTester.run('no-unknown-property', rule, {
{ code: '<input type="checkbox" checked={checked} disabled={disabled} id={id} onChange={onChange} />' },
{ code: '<video playsInline />' },
{ code: '<img onError={foo} onLoad={bar} />' },
{ code: '<picture onError={foo} onLoad={bar} />' },
{ code: '<iframe onError={foo} onLoad={bar} />' },
{ code: '<script onLoad={bar} onError={foo} />' },
{ code: '<source onError={foo} />' },
{ code: '<link onLoad={bar} onError={foo} />' },
Expand Down Expand Up @@ -400,7 +402,7 @@ ruleTester.run('no-unknown-property', rule, {
data: {
name: 'onError',
tagName: 'div',
allowedTags: 'audio, video, img, link, source, script',
allowedTags: 'audio, video, img, link, source, script, picture, iframe',
},
},
],
Expand All @@ -413,7 +415,7 @@ ruleTester.run('no-unknown-property', rule, {
data: {
name: 'onLoad',
tagName: 'div',
allowedTags: 'script, img, link',
allowedTags: 'script, img, link, picture, iframe',
},
},
],
Expand Down

0 comments on commit 033fcc5

Please sign in to comment.