Skip to content

Commit 1a75017

Browse files
committed
[Fix] no-unknown-property: allow onLoad on source
See #3505 (comment)
1 parent adebc71 commit 1a75017

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange
1111
### Fixed
1212
* [`no-array-index-key`]: consider flatMap ([#3530][] @k-yle)
1313
* [`jsx-curly-brace-presence`]: handle single and only expression template literals ([#3538][] @taozhou-glean)
14+
* [`no-unknown-property`]: allow `onLoad` on `source` (@ljharb)
1415

1516
[#3538]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3538
1617
[#3530]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3530

lib/rules/no-unknown-property.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ const ATTRIBUTE_TAGS_MAP = {
8181
onEncrypted: ['audio', 'video'],
8282
onEnded: ['audio', 'video'],
8383
onError: ['audio', 'video', 'img', 'link', 'source', 'script', 'picture', 'iframe'],
84-
onLoad: ['script', 'img', 'link', 'picture', 'iframe', 'object'],
84+
onLoad: ['script', 'img', 'link', 'picture', 'iframe', 'object', 'source'],
8585
onLoadedData: ['audio', 'video'],
8686
onLoadedMetadata: ['audio', 'video'],
8787
onLoadStart: ['audio', 'video'],

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ ruleTester.run('no-unknown-property', rule, {
6565
{ code: '<picture inert={false} onError={foo} onLoad={bar} />' },
6666
{ code: '<iframe onError={foo} onLoad={bar} />' },
6767
{ code: '<script onLoad={bar} onError={foo} />' },
68-
{ code: '<source onError={foo} />' },
68+
{ code: '<source onLoad={bar} onError={foo} />' },
6969
{ code: '<link onLoad={bar} onError={foo} />' },
7070
{ code: '<link rel="preload" as="image" href="someHref" imageSrcSet="someImageSrcSet" imageSizes="someImageSizes" />' },
7171
{ code: '<object onLoad={bar} />' },
@@ -459,7 +459,7 @@ ruleTester.run('no-unknown-property', rule, {
459459
data: {
460460
name: 'onLoad',
461461
tagName: 'div',
462-
allowedTags: 'script, img, link, picture, iframe, object',
462+
allowedTags: 'script, img, link, picture, iframe, object, source',
463463
},
464464
},
465465
],

0 commit comments

Comments
 (0)