Skip to content

Commit e8356ad

Browse files
committed
[Fix] no-unknown-property: add border; focusable on <svg>
Fixes #3404. Fixes #3405.
1 parent 3306b92 commit e8356ad

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,12 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange
1414
* [`no-unknown-property`]: Add more one word properties found in DefinitelyTyped's react/index.d.ts ([#3402][] @sjarva)
1515
* [`no-unknown-property`]: Mark onLoad/onError as supported on iframes ([#3398][] @maiis, [#3406][] @akx)
1616
* [`no-unknown-property`]: allow `imageSrcSet` and `imageSizes` attributes on `<link>` ([#3407][] @terrymun)
17+
* [`no-unknown-property`]: add `border`; `focusable` on `<svg>` ([#3404][] [#3404][] @ljharb)
1718

1819
[#3407]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3407
1920
[#3406]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3406
21+
[#3405]: https://github.com/jsx-eslint/eslint-plugin-react/issues/3405
22+
[#3404]: https://github.com/jsx-eslint/eslint-plugin-react/issues/3404
2023
[#3402]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3402
2124
[#3398]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3398
2225
[#3397]: https://github.com/jsx-eslint/eslint-plugin-react/issues/3397

lib/rules/no-unknown-property.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ const ATTRIBUTE_TAGS_MAP = {
5757
'animateTransform',
5858
'set',
5959
],
60+
focusable: ['svg'],
6061
imageSizes: ['link'],
6162
imageSrcSet: ['link'],
6263
property: ['meta'],
@@ -230,7 +231,7 @@ const DOM_PROPERTY_NAMES_TWO_WORDS = [
230231
// Element specific attributes
231232
// See https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes (includes global attributes too)
232233
// To be considered if these should be added also to ATTRIBUTE_TAGS_MAP
233-
'acceptCharset', 'autoComplete', 'autoPlay', 'cellPadding', 'cellSpacing', 'classID', 'codeBase',
234+
'acceptCharset', 'autoComplete', 'autoPlay', 'border', 'cellPadding', 'cellSpacing', 'classID', 'codeBase',
234235
'colSpan', 'contextMenu', 'dateTime', 'encType', 'formAction', 'formEncType', 'formMethod', 'formNoValidate', 'formTarget',
235236
'frameBorder', 'hrefLang', 'httpEquiv', 'imageSizes', 'imageSrcSet', 'isMap', 'keyParams', 'keyType', 'marginHeight', 'marginWidth',
236237
'maxLength', 'mediaGroup', 'minLength', 'noValidate', 'onAnimationEnd', 'onAnimationIteration', 'onAnimationStart',

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ ruleTester.run('no-unknown-property', rule, {
6767
{ code: '<link onLoad={bar} onError={foo} />' },
6868
{ code: '<link rel="preload" as="image" href="someHref" imageSrcSet="someImageSrcSet" imageSizes="someImageSizes" />' },
6969
{ code: '<div allowFullScreen webkitAllowFullScreen mozAllowFullScreen />' },
70+
{ code: '<table border="1" />' },
7071
{
7172
code: '<div allowTransparency="true" />',
7273
settings: {
@@ -110,7 +111,7 @@ ruleTester.run('no-unknown-property', rule, {
110111
// Attributes on allowed elements should work
111112
{ code: '<script crossOrigin />' },
112113
{ code: '<audio crossOrigin />' },
113-
{ code: '<svg><image crossOrigin /></svg>' },
114+
{ code: '<svg focusable><image crossOrigin /></svg>' },
114115
{ code: '<details onToggle={this.onToggle}>Some details</details>' },
115116
{ code: '<path fill="pink" d="M 10,30 A 20,20 0,0,1 50,30 A 20,20 0,0,1 90,30 Q 90,60 50,90 Q 10,60 10,30 z"></path>' },
116117
{ code: '<line fill="pink" x1="0" y1="80" x2="100" y2="20"></line>' },

0 commit comments

Comments
 (0)