4
4
*/
5
5
'use strict' ;
6
6
7
+ var versionUtil = require ( '../util/version' ) ;
8
+
7
9
// ------------------------------------------------------------------------------
8
10
// Constants
9
11
// ------------------------------------------------------------------------------
10
12
11
13
var UNKNOWN_MESSAGE = 'Unknown property \'{{name}}\' found, use \'{{standardName}}\' instead' ;
12
14
13
15
var DOM_ATTRIBUTE_NAMES = {
14
- // Standard
15
16
'accept-charset' : 'acceptCharset' ,
16
17
class : 'className' ,
17
18
for : 'htmlFor' ,
18
- 'http-equiv' : 'httpEquiv' ,
19
- // SVG
19
+ 'http-equiv' : 'httpEquiv'
20
+ } ;
21
+
22
+ var SVGDOM_ATTRIBUTE_NAMES = {
20
23
'clip-path' : 'clipPath' ,
21
24
'fill-opacity' : 'fillOpacity' ,
22
25
'font-family' : 'fontFamily' ,
@@ -87,13 +90,18 @@ function isTagName(node) {
87
90
88
91
/**
89
92
* Get the standard name of the attribute.
93
+ * @param {Object } context The current rule context.
90
94
* @param {String } name - Name of the attribute.
91
95
* @returns {String } The standard name of the attribute.
92
96
*/
93
- function getStandardName ( name ) {
97
+ function getStandardName ( context , name ) {
94
98
if ( DOM_ATTRIBUTE_NAMES [ name ] ) {
95
99
return DOM_ATTRIBUTE_NAMES [ name ] ;
96
100
}
101
+ // Also check for SVG attribute for React <15
102
+ if ( ! versionUtil . test ( context , '15.0.0' ) && SVGDOM_ATTRIBUTE_NAMES [ name ] ) {
103
+ return SVGDOM_ATTRIBUTE_NAMES [ name ] ;
104
+ }
97
105
var i ;
98
106
var found = DOM_PROPERTY_NAMES . some ( function ( element , index ) {
99
107
i = index ;
@@ -114,7 +122,7 @@ module.exports = function(context) {
114
122
115
123
JSXAttribute : function ( node ) {
116
124
var name = sourceCode . getText ( node . name ) ;
117
- var standardName = getStandardName ( name ) ;
125
+ var standardName = getStandardName ( context , name ) ;
118
126
if ( ! isTagName ( node ) || ! standardName ) {
119
127
return ;
120
128
}
0 commit comments