Skip to content

Commit 2145e29

Browse files
zpaoljharb
authored andcommitted
[New] no-unknown-property: Allow crossOrigin on image tag (SVG)
Fixes #3250
1 parent 567bc7d commit 2145e29

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange
77

88
### Added
99
* [`destructuring-assignment`]: add option `destructureInSignature` ([#3235][] @golopot)
10+
* [`no-unknown-property`]: Allow crossOrigin on image tag (SVG) ([#3251][] @zpao)
1011

1112
### Fixed
1213
* [`hook-use-state`]: Allow UPPERCASE setState setter prefixes ([#3244][] @duncanbeevers)
1314
* `propTypes`: add `VFC` to react generic type param map ([#3230][] @dlech)
1415

16+
[#3251]: https://github.com/yannickcr/eslint-plugin-react/pull/3251
1517
[#3244]: https://github.com/yannickcr/eslint-plugin-react/pull/3244
1618
[#3235]: https://github.com/yannickcr/eslint-plugin-react/pull/3235
1719
[#3230]: https://github.com/yannickcr/eslint-plugin-react/issues/3230

lib/rules/no-unknown-property.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ const DOM_ATTRIBUTE_NAMES = {
2727
};
2828

2929
const ATTRIBUTE_TAGS_MAP = {
30-
crossOrigin: ['script', 'img', 'video', 'audio', 'link'],
30+
// image is required for SVG support, all other tags are HTML.
31+
crossOrigin: ['script', 'img', 'video', 'audio', 'link', 'image'],
3132
};
3233

3334
const SVGDOM_ATTRIBUTE_NAMES = {

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ ruleTester.run('no-unknown-property', rule, {
5353
{ code: '<script crossOrigin />' },
5454
{ code: '<audio crossOrigin />' },
5555
{ code: '<div hasOwnProperty="should not be allowed tag" />' },
56+
{ code: '<svg><image crossOrigin /></svg>' },
5657
]),
5758
invalid: parsers.all([
5859
{
@@ -220,7 +221,7 @@ ruleTester.run('no-unknown-property', rule, {
220221
data: {
221222
name: 'crossOrigin',
222223
tagName: 'div',
223-
allowedTags: 'script, img, video, audio, link',
224+
allowedTags: 'script, img, video, audio, link, image',
224225
},
225226
},
226227
],

0 commit comments

Comments
 (0)