Skip to content

Commit fd08120

Browse files
DerekStapletonljharb
authored andcommitted
[Fix] no-unknown-property: allow onLoad on body
They body tag supports an onload event https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/load_event
1 parent 3a03579 commit fd08120

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

CHANGELOG.md

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

77
## Unreleased
88

9+
### Fixed
10+
* [`no-unknown-property`]: allow `onLoad` on `body` ([#3923][] @DerekStapleton)
11+
12+
[#3923]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3923
13+
914
## [7.37.5] - 2025.04.03
1015

1116
### Fixed

lib/rules/no-unknown-property.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ const ATTRIBUTE_TAGS_MAP = {
8585
onEncrypted: ['audio', 'video'],
8686
onEnded: ['audio', 'video'],
8787
onError: ['audio', 'video', 'img', 'link', 'source', 'script', 'picture', 'iframe'],
88-
onLoad: ['script', 'img', 'link', 'picture', 'iframe', 'object', 'source'],
88+
onLoad: ['script', 'img', 'link', 'picture', 'iframe', 'object', 'source', 'body'],
8989
onLoadedData: ['audio', 'video'],
9090
onLoadedMetadata: ['audio', 'video'],
9191
onLoadStart: ['audio', 'video'],

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ ruleTester.run('no-unknown-property', rule, {
7474
{ code: '<link onLoad={bar} onError={foo} />' },
7575
{ code: '<link rel="preload" as="image" href="someHref" imageSrcSet="someImageSrcSet" imageSizes="someImageSizes" />' },
7676
{ code: '<object onLoad={bar} />' },
77+
{ code: '<body onLoad={bar} />' },
7778
{ code: '<video allowFullScreen webkitAllowFullScreen mozAllowFullScreen />' },
7879
{ code: '<iframe allowFullScreen webkitAllowFullScreen mozAllowFullScreen />' },
7980
{ code: '<table border="1" />' },
@@ -509,7 +510,7 @@ ruleTester.run('no-unknown-property', rule, {
509510
data: {
510511
name: 'onLoad',
511512
tagName: 'div',
512-
allowedTags: 'script, img, link, picture, iframe, object, source',
513+
allowedTags: 'script, img, link, picture, iframe, object, source, body',
513514
},
514515
},
515516
],

0 commit comments

Comments
 (0)