From fd08120ddbe15a4d2fb510c6ed705314d38201f0 Mon Sep 17 00:00:00 2001
From: derek stapleton
Date: Mon, 5 May 2025 14:44:25 -0500
Subject: [PATCH] [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
---
CHANGELOG.md | 5 +++++
lib/rules/no-unknown-property.js | 2 +-
tests/lib/rules/no-unknown-property.js | 3 ++-
3 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 002a1ed942..ddbbfef5c8 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,6 +6,11 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange
## Unreleased
+### Fixed
+* [`no-unknown-property`]: allow `onLoad` on `body` ([#3923][] @DerekStapleton)
+
+[#3923]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3923
+
## [7.37.5] - 2025.04.03
### Fixed
diff --git a/lib/rules/no-unknown-property.js b/lib/rules/no-unknown-property.js
index d702cc4303..ff87d2f0ff 100644
--- a/lib/rules/no-unknown-property.js
+++ b/lib/rules/no-unknown-property.js
@@ -85,7 +85,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', 'source'],
+ onLoad: ['script', 'img', 'link', 'picture', 'iframe', 'object', 'source', 'body'],
onLoadedData: ['audio', 'video'],
onLoadedMetadata: ['audio', 'video'],
onLoadStart: ['audio', 'video'],
diff --git a/tests/lib/rules/no-unknown-property.js b/tests/lib/rules/no-unknown-property.js
index f24257a04d..ab0d5fb6d0 100644
--- a/tests/lib/rules/no-unknown-property.js
+++ b/tests/lib/rules/no-unknown-property.js
@@ -74,6 +74,7 @@ ruleTester.run('no-unknown-property', rule, {
{ code: '' },
{ code: '' },
{ code: '' },
+ { code: '' },
{ code: '' },
{ code: '' },
{ code: '
' },
@@ -509,7 +510,7 @@ ruleTester.run('no-unknown-property', rule, {
data: {
name: 'onLoad',
tagName: 'div',
- allowedTags: 'script, img, link, picture, iframe, object, source',
+ allowedTags: 'script, img, link, picture, iframe, object, source, body',
},
},
],