Skip to content

Commit 033fcc5

Browse files
maiisakx
authored andcommitted
[Fix] no-unknown-property: add onError and onLoad for iframe/picture
Fixes #3410. Co-authored-by: Emmanuel Vuigner <[email protected]> Co-authored-by: Aarni Koskela <[email protected]>
1 parent 1c0c92b commit 033fcc5

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,11 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange
1212
* [`no-unknown-property`]: `controlsList`, not `controlList` ([#3397][] @ljharb)
1313
* [`no-unknown-property`]: add more capture event properties ([#3402][] @sjarva)
1414
* [`no-unknown-property`]: Add more one word properties found in DefinitelyTyped's react/index.d.ts ([#3402][] @sjarva)
15+
* [`no-unknown-property`]: Mark onLoad/onError as supported on iframes ([#3398][] @maiis, [#3406][] @akx)
1516

17+
[#3406]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3406
1618
[#3402]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3402
19+
[#3398]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3398
1720
[#3397]: https://github.com/jsx-eslint/eslint-plugin-react/issues/3397
1821
[#3396]: https://github.com/jsx-eslint/eslint-plugin-react/issues/3396
1922
[#3394]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3394

lib/rules/no-unknown-property.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ const ATTRIBUTE_TAGS_MAP = {
6868
onEmptied: ['audio', 'video'],
6969
onEncrypted: ['audio', 'video'],
7070
onEnded: ['audio', 'video'],
71-
onError: ['audio', 'video', 'img', 'link', 'source', 'script'],
72-
onLoad: ['script', 'img', 'link'],
71+
onError: ['audio', 'video', 'img', 'link', 'source', 'script', 'picture', 'iframe'],
72+
onLoad: ['script', 'img', 'link', 'picture', 'iframe'],
7373
onLoadedData: ['audio', 'video'],
7474
onLoadedMetadata: ['audio', 'video'],
7575
onLoadStart: ['audio', 'video'],

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

+5-3
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ ruleTester.run('no-unknown-property', rule, {
5050
{ code: '<input type="password" required />' },
5151
{ code: '<input ref={this.input} type="radio" />' },
5252
{ code: '<div children="anything" />' },
53-
{ code: '<iframe scrolling="?" />' },
53+
{ code: '<iframe scrolling="?" onLoad={a} onError={b} />' },
5454
{ code: '<input key="bar" type="radio" />' },
5555
{ code: '<button disabled>You cannot click me</button>;' },
5656
{ 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>' },
@@ -60,6 +60,8 @@ ruleTester.run('no-unknown-property', rule, {
6060
{ code: '<input type="checkbox" checked={checked} disabled={disabled} id={id} onChange={onChange} />' },
6161
{ code: '<video playsInline />' },
6262
{ code: '<img onError={foo} onLoad={bar} />' },
63+
{ code: '<picture onError={foo} onLoad={bar} />' },
64+
{ code: '<iframe onError={foo} onLoad={bar} />' },
6365
{ code: '<script onLoad={bar} onError={foo} />' },
6466
{ code: '<source onError={foo} />' },
6567
{ code: '<link onLoad={bar} onError={foo} />' },
@@ -400,7 +402,7 @@ ruleTester.run('no-unknown-property', rule, {
400402
data: {
401403
name: 'onError',
402404
tagName: 'div',
403-
allowedTags: 'audio, video, img, link, source, script',
405+
allowedTags: 'audio, video, img, link, source, script, picture, iframe',
404406
},
405407
},
406408
],
@@ -413,7 +415,7 @@ ruleTester.run('no-unknown-property', rule, {
413415
data: {
414416
name: 'onLoad',
415417
tagName: 'div',
416-
allowedTags: 'script, img, link',
418+
allowedTags: 'script, img, link, picture, iframe',
417419
},
418420
},
419421
],

0 commit comments

Comments
 (0)