Skip to content

Commit

Permalink
[Fix] no-unknown-property: allow onLoad on source
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Mar 14, 2023
1 parent adebc71 commit 1a75017
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -11,6 +11,7 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange
### Fixed
* [`no-array-index-key`]: consider flatMap ([#3530][] @k-yle)
* [`jsx-curly-brace-presence`]: handle single and only expression template literals ([#3538][] @taozhou-glean)
* [`no-unknown-property`]: allow `onLoad` on `source` (@ljharb)

[#3538]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3538
[#3530]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3530
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/no-unknown-property.js
Expand Up @@ -81,7 +81,7 @@ const ATTRIBUTE_TAGS_MAP = {
onEncrypted: ['audio', 'video'],
onEnded: ['audio', 'video'],
onError: ['audio', 'video', 'img', 'link', 'source', 'script', 'picture', 'iframe'],
onLoad: ['script', 'img', 'link', 'picture', 'iframe', 'object'],
onLoad: ['script', 'img', 'link', 'picture', 'iframe', 'object', 'source'],
onLoadedData: ['audio', 'video'],
onLoadedMetadata: ['audio', 'video'],
onLoadStart: ['audio', 'video'],
Expand Down
4 changes: 2 additions & 2 deletions tests/lib/rules/no-unknown-property.js
Expand Up @@ -65,7 +65,7 @@ ruleTester.run('no-unknown-property', rule, {
{ code: '<picture inert={false} onError={foo} onLoad={bar} />' },
{ code: '<iframe onError={foo} onLoad={bar} />' },
{ code: '<script onLoad={bar} onError={foo} />' },
{ code: '<source onError={foo} />' },
{ code: '<source onLoad={bar} onError={foo} />' },
{ code: '<link onLoad={bar} onError={foo} />' },
{ code: '<link rel="preload" as="image" href="someHref" imageSrcSet="someImageSrcSet" imageSizes="someImageSizes" />' },
{ code: '<object onLoad={bar} />' },
Expand Down Expand Up @@ -459,7 +459,7 @@ ruleTester.run('no-unknown-property', rule, {
data: {
name: 'onLoad',
tagName: 'div',
allowedTags: 'script, img, link, picture, iframe, object',
allowedTags: 'script, img, link, picture, iframe, object, source',
},
},
],
Expand Down

0 comments on commit 1a75017

Please sign in to comment.