Move HTML and SVG configs into DOMProperty (#11728)
* Inline HTML and SVG configs into DOMProperty * Replace invariants with warnings These invariants can only happen if *we* mess up, and happen during init time. So it's safe to make these warnings, as they would fail the tests anyway. * Clearer variable naming
Dan Abramov committed
Nov 30, 2017 at 22:29 UTC
8ec2ed4089053e6eaf00de6e9bddc793d27b74e8
7 files changed
+266
-337
packages/react-dom/src/client/ReactDOM.js
-1
@@ -16,7 +16,6 @@ import type {
16
} from 'react-reconciler/src/ReactFiberRoot';
17
18
import '../shared/checkReact';
19
-import '../shared/ReactDOMInjection';
19
import './ReactDOMClientInjection';
20
21
import ReactFiberReconciler from 'react-reconciler';
packages/react-dom/src/server/ReactDOMServerBrowser.js
-1
@@ -5,7 +5,6 @@
5
* LICENSE file in the root directory of this source tree.
6
*/
7
8
-import '../shared/ReactDOMInjection';
8
import ReactVersion from 'shared/ReactVersion';
9
import invariant from 'fbjs/lib/invariant';
10
packages/react-dom/src/server/ReactDOMServerNode.js
-1
@@ -5,7 +5,6 @@
5
* LICENSE file in the root directory of this source tree.
6
*/
7
8
-import '../shared/ReactDOMInjection';
8
import ReactVersion from 'shared/ReactVersion';
9
10
import {renderToString, renderToStaticMarkup} from './ReactDOMStringRenderer';
packages/react-dom/src/shared/DOMProperty.js
+266
-82
@@ -5,7 +5,7 @@
5
* LICENSE file in the root directory of this source tree.
6
*/
7
8
-import invariant from 'fbjs/lib/invariant';
8
+import warning from 'fbjs/lib/warning';
9
10
// These attributes should be all lowercase to allow for
11
// case insensitive checks
@@ -24,46 +24,21 @@ function checkMask(value, bitmask) {
24
return (value & bitmask) === bitmask;
25
}
26
27
-var DOMPropertyInjection = {
28
- /**
29
- * Mapping from normalized, camelcased property names to a configuration that
30
- * specifies how the associated DOM property should be accessed or rendered.
31
- */
32
- MUST_USE_PROPERTY: 0x1,
33
- HAS_BOOLEAN_VALUE: 0x4,
34
- HAS_NUMERIC_VALUE: 0x8,
35
- HAS_POSITIVE_NUMERIC_VALUE: 0x10 | 0x8,
36
- HAS_OVERLOADED_BOOLEAN_VALUE: 0x20,
37
- HAS_STRING_BOOLEAN_VALUE: 0x40,
38
-
39
- /**
40
- * Inject some specialized knowledge about the DOM. This takes a config object
41
- * with the following properties:
42
- *
43
- * Properties: object mapping DOM property name to one of the
44
- * DOMPropertyInjection constants or null. If your attribute isn't in here,
45
- * it won't get written to the DOM.
46
- *
47
- * DOMAttributeNames: object mapping React attribute name to the DOM
48
- * attribute name. Attribute names not specified use the **lowercase**
49
- * normalized name.
50
- *
51
- * DOMAttributeNamespaces: object mapping React attribute name to the DOM
52
- * attribute namespace URL. (Attribute names not specified use no namespace.)
53
- *
54
- * DOMPropertyNames: similar to DOMAttributeNames but for DOM properties.
55
- * Property names not specified use the normalized name.
56
- *
57
- * @param {object} domPropertyConfig the config as described above.
58
- */
59
- injectDOMPropertyConfig: function(domPropertyConfig) {
60
- var Injection = DOMPropertyInjection;
61
- var Properties = domPropertyConfig.Properties || {};
62
- var DOMAttributeNamespaces = domPropertyConfig.DOMAttributeNamespaces || {};
63
- var DOMAttributeNames = domPropertyConfig.DOMAttributeNames || {};
64
-
65
- for (var propName in Properties) {
66
- invariant(
27
+const MUST_USE_PROPERTY = 0x1;
28
+const HAS_BOOLEAN_VALUE = 0x4;
29
+const HAS_NUMERIC_VALUE = 0x8;
30
+const HAS_POSITIVE_NUMERIC_VALUE = 0x10 | 0x8;
31
+const HAS_OVERLOADED_BOOLEAN_VALUE = 0x20;
32
+const HAS_STRING_BOOLEAN_VALUE = 0x40;
33
+
34
+function injectDOMPropertyConfig(domPropertyConfig) {
35
+ var Properties = domPropertyConfig.Properties || {};
36
+ var DOMAttributeNamespaces = domPropertyConfig.DOMAttributeNamespaces || {};
37
+ var DOMAttributeNames = domPropertyConfig.DOMAttributeNames || {};
38
+
39
+ for (var propName in Properties) {
40
+ if (__DEV__) {
41
+ warning(
42
!properties.hasOwnProperty(propName),
43
"injectDOMPropertyConfig(...): You're trying to inject DOM property " +
44
"'%s' which has already been injected. You may be accidentally " +
@@ -71,32 +46,31 @@ var DOMPropertyInjection = {
46
'injecting two configs that have conflicting property names.',
47
propName,
48
);
49
+ }
50
+
51
+ var lowerCased = propName.toLowerCase();
52
+ var propConfig = Properties[propName];
53
75
- var lowerCased = propName.toLowerCase();
76
- var propConfig = Properties[propName];
77
-
78
- var propertyInfo = {
79
- attributeName: lowerCased,
80
- attributeNamespace: null,
81
- propertyName: propName,
82
-
83
- mustUseProperty: checkMask(propConfig, Injection.MUST_USE_PROPERTY),
84
- hasBooleanValue: checkMask(propConfig, Injection.HAS_BOOLEAN_VALUE),
85
- hasNumericValue: checkMask(propConfig, Injection.HAS_NUMERIC_VALUE),
86
- hasPositiveNumericValue: checkMask(
87
- propConfig,
88
- Injection.HAS_POSITIVE_NUMERIC_VALUE,
89
- ),
90
- hasOverloadedBooleanValue: checkMask(
91
- propConfig,
92
- Injection.HAS_OVERLOADED_BOOLEAN_VALUE,
93
- ),
94
- hasStringBooleanValue: checkMask(
95
- propConfig,
96
- Injection.HAS_STRING_BOOLEAN_VALUE,
97
- ),
98
- };
99
- invariant(
54
+ var propertyInfo = {
55
+ attributeName: lowerCased,
56
+ attributeNamespace: null,
57
+ propertyName: propName,
58
+
59
+ mustUseProperty: checkMask(propConfig, MUST_USE_PROPERTY),
60
+ hasBooleanValue: checkMask(propConfig, HAS_BOOLEAN_VALUE),
61
+ hasNumericValue: checkMask(propConfig, HAS_NUMERIC_VALUE),
62
+ hasPositiveNumericValue: checkMask(
63
+ propConfig,
64
+ HAS_POSITIVE_NUMERIC_VALUE,
65
+ ),
66
+ hasOverloadedBooleanValue: checkMask(
67
+ propConfig,
68
+ HAS_OVERLOADED_BOOLEAN_VALUE,
69
+ ),
70
+ hasStringBooleanValue: checkMask(propConfig, HAS_STRING_BOOLEAN_VALUE),
71
+ };
72
+ if (__DEV__) {
73
+ warning(
74
propertyInfo.hasBooleanValue +
75
propertyInfo.hasNumericValue +
76
propertyInfo.hasOverloadedBooleanValue <=
@@ -105,25 +79,25 @@ var DOMPropertyInjection = {
79
'numeric value, but not a combination: %s',
80
propName,
81
);
82
+ }
83
109
- if (DOMAttributeNames.hasOwnProperty(propName)) {
110
- var attributeName = DOMAttributeNames[propName];
111
-
112
- propertyInfo.attributeName = attributeName;
113
- }
84
+ if (DOMAttributeNames.hasOwnProperty(propName)) {
85
+ var attributeName = DOMAttributeNames[propName];
86
115
- if (DOMAttributeNamespaces.hasOwnProperty(propName)) {
116
- propertyInfo.attributeNamespace = DOMAttributeNamespaces[propName];
117
- }
87
+ propertyInfo.attributeName = attributeName;
88
+ }
89
119
- // Downcase references to whitelist properties to check for membership
120
- // without case-sensitivity. This allows the whitelist to pick up
121
- // `allowfullscreen`, which should be written using the property configuration
122
- // for `allowFullscreen`
123
- properties[propName] = propertyInfo;
90
+ if (DOMAttributeNamespaces.hasOwnProperty(propName)) {
91
+ propertyInfo.attributeNamespace = DOMAttributeNamespaces[propName];
92
}
125
- },
126
-};
93
+
94
+ // Downcase references to whitelist properties to check for membership
95
+ // without case-sensitivity. This allows the whitelist to pick up
96
+ // `allowfullscreen`, which should be written using the property configuration
97
+ // for `allowFullscreen`
98
+ properties[propName] = propertyInfo;
99
+ }
100
+}
101
102
/* eslint-disable max-len */
103
export const ATTRIBUTE_NAME_START_CHAR =
@@ -227,4 +201,214 @@ export function isReservedProp(name) {
201
return RESERVED_PROPS.hasOwnProperty(name);
202
}
203
230
-export const injection = DOMPropertyInjection;
204
+var HTMLDOMPropertyConfig = {
205
+ // When adding attributes to this list, be sure to also add them to
206
+ // the `possibleStandardNames` module to ensure casing and incorrect
207
+ // name warnings.
208
+ Properties: {
209
+ allowFullScreen: HAS_BOOLEAN_VALUE,
210
+ // specifies target context for links with `preload` type
211
+ async: HAS_BOOLEAN_VALUE,
212
+ // Note: there is a special case that prevents it from being written to the DOM
213
+ // on the client side because the browsers are inconsistent. Instead we call focus().
214
+ autoFocus: HAS_BOOLEAN_VALUE,
215
+ autoPlay: HAS_BOOLEAN_VALUE,
216
+ capture: HAS_OVERLOADED_BOOLEAN_VALUE,
217
+ checked: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE,
218
+ cols: HAS_POSITIVE_NUMERIC_VALUE,
219
+ contentEditable: HAS_STRING_BOOLEAN_VALUE,
220
+ controls: HAS_BOOLEAN_VALUE,
221
+ default: HAS_BOOLEAN_VALUE,
222
+ defer: HAS_BOOLEAN_VALUE,
223
+ disabled: HAS_BOOLEAN_VALUE,
224
+ download: HAS_OVERLOADED_BOOLEAN_VALUE,
225
+ draggable: HAS_STRING_BOOLEAN_VALUE,
226
+ formNoValidate: HAS_BOOLEAN_VALUE,
227
+ hidden: HAS_BOOLEAN_VALUE,
228
+ loop: HAS_BOOLEAN_VALUE,
229
+ // Caution; `option.selected` is not updated if `select.multiple` is
230
+ // disabled with `removeAttribute`.
231
+ multiple: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE,
232
+ muted: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE,
233
+ noValidate: HAS_BOOLEAN_VALUE,
234
+ open: HAS_BOOLEAN_VALUE,
235
+ playsInline: HAS_BOOLEAN_VALUE,
236
+ readOnly: HAS_BOOLEAN_VALUE,
237
+ required: HAS_BOOLEAN_VALUE,
238
+ reversed: HAS_BOOLEAN_VALUE,
239
+ rows: HAS_POSITIVE_NUMERIC_VALUE,
240
+ rowSpan: HAS_NUMERIC_VALUE,
241
+ scoped: HAS_BOOLEAN_VALUE,
242
+ seamless: HAS_BOOLEAN_VALUE,
243
+ selected: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE,
244
+ size: HAS_POSITIVE_NUMERIC_VALUE,
245
+ start: HAS_NUMERIC_VALUE,
246
+ // support for projecting regular DOM Elements via V1 named slots ( shadow dom )
247
+ span: HAS_POSITIVE_NUMERIC_VALUE,
248
+ spellCheck: HAS_STRING_BOOLEAN_VALUE,
249
+ // Style must be explicitly set in the attribute list. React components
250
+ // expect a style object
251
+ style: 0,
252
+ // Keep it in the whitelist because it is case-sensitive for SVG.
253
+ tabIndex: 0,
254
+ // itemScope is for for Microdata support.
255
+ // See http://schema.org/docs/gs.html
256
+ itemScope: HAS_BOOLEAN_VALUE,
257
+ // These attributes must stay in the white-list because they have
258
+ // different attribute names (see DOMAttributeNames below)
259
+ acceptCharset: 0,
260
+ className: 0,
261
+ htmlFor: 0,
262
+ httpEquiv: 0,
263
+ // Set the string boolean flag to allow the behavior
264
+ value: HAS_STRING_BOOLEAN_VALUE,
265
+ },
266
+ DOMAttributeNames: {
267
+ acceptCharset: 'accept-charset',
268
+ className: 'class',
269
+ htmlFor: 'for',
270
+ httpEquiv: 'http-equiv',
271
+ },
272
+};
273
+
274
+var NS = {
275
+ xlink: 'http://www.w3.org/1999/xlink',
276
+ xml: 'http://www.w3.org/XML/1998/namespace',
277
+};
278
+
279
+/**
280
+ * This is a list of all SVG attributes that need special casing,
281
+ * namespacing, or boolean value assignment.
282
+ *
283
+ * When adding attributes to this list, be sure to also add them to
284
+ * the `possibleStandardNames` module to ensure casing and incorrect
285
+ * name warnings.
286
+ *
287
+ * SVG Attributes List:
288
+ * https://www.w3.org/TR/SVG/attindex.html
289
+ * SMIL Spec:
290
+ * https://www.w3.org/TR/smil
291
+ */
292
+var SVG_ATTRS = [
293
+ 'accent-height',
294
+ 'alignment-baseline',
295
+ 'arabic-form',
296
+ 'baseline-shift',
297
+ 'cap-height',
298
+ 'clip-path',
299
+ 'clip-rule',
300
+ 'color-interpolation',
301
+ 'color-interpolation-filters',
302
+ 'color-profile',
303
+ 'color-rendering',
304
+ 'dominant-baseline',
305
+ 'enable-background',
306
+ 'fill-opacity',
307
+ 'fill-rule',
308
+ 'flood-color',
309
+ 'flood-opacity',
310
+ 'font-family',
311
+ 'font-size',
312
+ 'font-size-adjust',
313
+ 'font-stretch',
314
+ 'font-style',
315
+ 'font-variant',
316
+ 'font-weight',
317
+ 'glyph-name',
318
+ 'glyph-orientation-horizontal',
319
+ 'glyph-orientation-vertical',
320
+ 'horiz-adv-x',
321
+ 'horiz-origin-x',
322
+ 'image-rendering',
323
+ 'letter-spacing',
324
+ 'lighting-color',
325
+ 'marker-end',
326
+ 'marker-mid',
327
+ 'marker-start',
328
+ 'overline-position',
329
+ 'overline-thickness',
330
+ 'paint-order',
331
+ 'panose-1',
332
+ 'pointer-events',
333
+ 'rendering-intent',
334
+ 'shape-rendering',
335
+ 'stop-color',
336
+ 'stop-opacity',
337
+ 'strikethrough-position',
338
+ 'strikethrough-thickness',
339
+ 'stroke-dasharray',
340
+ 'stroke-dashoffset',
341
+ 'stroke-linecap',
342
+ 'stroke-linejoin',
343
+ 'stroke-miterlimit',
344
+ 'stroke-opacity',
345
+ 'stroke-width',
346
+ 'text-anchor',
347
+ 'text-decoration',
348
+ 'text-rendering',
349
+ 'underline-position',
350
+ 'underline-thickness',
351
+ 'unicode-bidi',
352
+ 'unicode-range',
353
+ 'units-per-em',
354
+ 'v-alphabetic',
355
+ 'v-hanging',
356
+ 'v-ideographic',
357
+ 'v-mathematical',
358
+ 'vector-effect',
359
+ 'vert-adv-y',
360
+ 'vert-origin-x',
361
+ 'vert-origin-y',
362
+ 'word-spacing',
363
+ 'writing-mode',
364
+ 'x-height',
365
+ 'xlink:actuate',
366
+ 'xlink:arcrole',
367
+ 'xlink:href',
368
+ 'xlink:role',
369
+ 'xlink:show',
370
+ 'xlink:title',
371
+ 'xlink:type',
372
+ 'xml:base',
373
+ 'xmlns:xlink',
374
+ 'xml:lang',
375
+ 'xml:space',
376
+];
377
+
378
+var SVGDOMPropertyConfig = {
379
+ Properties: {
380
+ autoReverse: HAS_STRING_BOOLEAN_VALUE,
381
+ externalResourcesRequired: HAS_STRING_BOOLEAN_VALUE,
382
+ preserveAlpha: HAS_STRING_BOOLEAN_VALUE,
383
+ },
384
+ DOMAttributeNames: {
385
+ autoReverse: 'autoReverse',
386
+ externalResourcesRequired: 'externalResourcesRequired',
387
+ preserveAlpha: 'preserveAlpha',
388
+ },
389
+ DOMAttributeNamespaces: {
390
+ xlinkActuate: NS.xlink,
391
+ xlinkArcrole: NS.xlink,
392
+ xlinkHref: NS.xlink,
393
+ xlinkRole: NS.xlink,
394
+ xlinkShow: NS.xlink,
395
+ xlinkTitle: NS.xlink,
396
+ xlinkType: NS.xlink,
397
+ xmlBase: NS.xml,
398
+ xmlLang: NS.xml,
399
+ xmlSpace: NS.xml,
400
+ },
401
+};
402
+
403
+var CAMELIZE = /[\-\:]([a-z])/g;
404
+var capitalize = token => token[1].toUpperCase();
405
+
406
+SVG_ATTRS.forEach(original => {
407
+ var reactName = original.replace(CAMELIZE, capitalize);
408
+
409
+ SVGDOMPropertyConfig.Properties[reactName] = 0;
410
+ SVGDOMPropertyConfig.DOMAttributeNames[reactName] = original;
411
+});
412
+
413
+injectDOMPropertyConfig(HTMLDOMPropertyConfig);
414
+injectDOMPropertyConfig(SVGDOMPropertyConfig);
packages/react-dom/src/shared/HTMLDOMPropertyConfig.js
deleted
-88
@@ -1,88 +0,0 @@
1
-/**
2
- * Copyright (c) 2013-present, Facebook, Inc.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- */
7
-
8
-import {injection} from './DOMProperty';
9
-
10
-var MUST_USE_PROPERTY = injection.MUST_USE_PROPERTY;
11
-var HAS_BOOLEAN_VALUE = injection.HAS_BOOLEAN_VALUE;
12
-var HAS_NUMERIC_VALUE = injection.HAS_NUMERIC_VALUE;
13
-var HAS_POSITIVE_NUMERIC_VALUE = injection.HAS_POSITIVE_NUMERIC_VALUE;
14
-var HAS_OVERLOADED_BOOLEAN_VALUE = injection.HAS_OVERLOADED_BOOLEAN_VALUE;
15
-var HAS_STRING_BOOLEAN_VALUE = injection.HAS_STRING_BOOLEAN_VALUE;
16
-
17
-var HTMLDOMPropertyConfig = {
18
- // When adding attributes to this list, be sure to also add them to
19
- // the `possibleStandardNames` module to ensure casing and incorrect
20
- // name warnings.
21
- Properties: {
22
- allowFullScreen: HAS_BOOLEAN_VALUE,
23
- // specifies target context for links with `preload` type
24
- async: HAS_BOOLEAN_VALUE,
25
- // Note: there is a special case that prevents it from being written to the DOM
26
- // on the client side because the browsers are inconsistent. Instead we call focus().
27
- autoFocus: HAS_BOOLEAN_VALUE,
28
- autoPlay: HAS_BOOLEAN_VALUE,
29
- capture: HAS_OVERLOADED_BOOLEAN_VALUE,
30
- checked: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE,
31
- cols: HAS_POSITIVE_NUMERIC_VALUE,
32
- contentEditable: HAS_STRING_BOOLEAN_VALUE,
33
- controls: HAS_BOOLEAN_VALUE,
34
- default: HAS_BOOLEAN_VALUE,
35
- defer: HAS_BOOLEAN_VALUE,
36
- disabled: HAS_BOOLEAN_VALUE,
37
- download: HAS_OVERLOADED_BOOLEAN_VALUE,
38
- draggable: HAS_STRING_BOOLEAN_VALUE,
39
- formNoValidate: HAS_BOOLEAN_VALUE,
40
- hidden: HAS_BOOLEAN_VALUE,
41
- loop: HAS_BOOLEAN_VALUE,
42
- // Caution; `option.selected` is not updated if `select.multiple` is
43
- // disabled with `removeAttribute`.
44
- multiple: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE,
45
- muted: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE,
46
- noValidate: HAS_BOOLEAN_VALUE,
47
- open: HAS_BOOLEAN_VALUE,
48
- playsInline: HAS_BOOLEAN_VALUE,
49
- readOnly: HAS_BOOLEAN_VALUE,
50
- required: HAS_BOOLEAN_VALUE,
51
- reversed: HAS_BOOLEAN_VALUE,
52
- rows: HAS_POSITIVE_NUMERIC_VALUE,
53
- rowSpan: HAS_NUMERIC_VALUE,
54
- scoped: HAS_BOOLEAN_VALUE,
55
- seamless: HAS_BOOLEAN_VALUE,
56
- selected: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE,
57
- size: HAS_POSITIVE_NUMERIC_VALUE,
58
- start: HAS_NUMERIC_VALUE,
59
- // support for projecting regular DOM Elements via V1 named slots ( shadow dom )
60
- span: HAS_POSITIVE_NUMERIC_VALUE,
61
- spellCheck: HAS_STRING_BOOLEAN_VALUE,
62
- // Style must be explicitly set in the attribute list. React components
63
- // expect a style object
64
- style: 0,
65
- // Keep it in the whitelist because it is case-sensitive for SVG.
66
- tabIndex: 0,
67
- // itemScope is for for Microdata support.
68
- // See http://schema.org/docs/gs.html
69
- itemScope: HAS_BOOLEAN_VALUE,
70
- // These attributes must stay in the white-list because they have
71
- // different attribute names (see DOMAttributeNames below)
72
- acceptCharset: 0,
73
- className: 0,
74
- htmlFor: 0,
75
- httpEquiv: 0,
76
- // Attributes with mutation methods must be specified in the whitelist
77
- // Set the string boolean flag to allow the behavior
78
- value: HAS_STRING_BOOLEAN_VALUE,
79
- },
80
- DOMAttributeNames: {
81
- acceptCharset: 'accept-charset',
82
- className: 'class',
83
- htmlFor: 'for',
84
- httpEquiv: 'http-equiv',
85
- },
86
-};
87
-
88
-export default HTMLDOMPropertyConfig;
packages/react-dom/src/shared/ReactDOMInjection.js
deleted
-13
@@ -1,13 +0,0 @@
1
-/**
2
- * Copyright (c) 2013-present, Facebook, Inc.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- */
7
-
8
-import * as DOMProperty from './DOMProperty';
9
-import HTMLDOMPropertyConfig from './HTMLDOMPropertyConfig';
10
-import SVGDOMPropertyConfig from './SVGDOMPropertyConfig';
11
-
12
-DOMProperty.injection.injectDOMPropertyConfig(HTMLDOMPropertyConfig);
13
-DOMProperty.injection.injectDOMPropertyConfig(SVGDOMPropertyConfig);
packages/react-dom/src/shared/SVGDOMPropertyConfig.js
deleted
-151
@@ -1,151 +0,0 @@
1
-/**
2
- * Copyright (c) 2013-present, Facebook, Inc.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- */
7
-
8
-import {injection} from './DOMProperty';
9
-
10
-var {HAS_STRING_BOOLEAN_VALUE} = injection;
11
-
12
-var NS = {
13
- xlink: 'http://www.w3.org/1999/xlink',
14
- xml: 'http://www.w3.org/XML/1998/namespace',
15
-};
16
-
17
-/**
18
- * This is a list of all SVG attributes that need special casing,
19
- * namespacing, or boolean value assignment.
20
- *
21
- * When adding attributes to this list, be sure to also add them to
22
- * the `possibleStandardNames` module to ensure casing and incorrect
23
- * name warnings.
24
- *
25
- * SVG Attributes List:
26
- * https://www.w3.org/TR/SVG/attindex.html
27
- * SMIL Spec:
28
- * https://www.w3.org/TR/smil
29
- */
30
-var ATTRS = [
31
- 'accent-height',
32
- 'alignment-baseline',
33
- 'arabic-form',
34
- 'baseline-shift',
35
- 'cap-height',
36
- 'clip-path',
37
- 'clip-rule',
38
- 'color-interpolation',
39
- 'color-interpolation-filters',
40
- 'color-profile',
41
- 'color-rendering',
42
- 'dominant-baseline',
43
- 'enable-background',
44
- 'fill-opacity',
45
- 'fill-rule',
46
- 'flood-color',
47
- 'flood-opacity',
48
- 'font-family',
49
- 'font-size',
50
- 'font-size-adjust',
51
- 'font-stretch',
52
- 'font-style',
53
- 'font-variant',
54
- 'font-weight',
55
- 'glyph-name',
56
- 'glyph-orientation-horizontal',
57
- 'glyph-orientation-vertical',
58
- 'horiz-adv-x',
59
- 'horiz-origin-x',
60
- 'image-rendering',
61
- 'letter-spacing',
62
- 'lighting-color',
63
- 'marker-end',
64
- 'marker-mid',
65
- 'marker-start',
66
- 'overline-position',
67
- 'overline-thickness',
68
- 'paint-order',
69
- 'panose-1',
70
- 'pointer-events',
71
- 'rendering-intent',
72
- 'shape-rendering',
73
- 'stop-color',
74
- 'stop-opacity',
75
- 'strikethrough-position',
76
- 'strikethrough-thickness',
77
- 'stroke-dasharray',
78
- 'stroke-dashoffset',
79
- 'stroke-linecap',
80
- 'stroke-linejoin',
81
- 'stroke-miterlimit',
82
- 'stroke-opacity',
83
- 'stroke-width',
84
- 'text-anchor',
85
- 'text-decoration',
86
- 'text-rendering',
87
- 'underline-position',
88
- 'underline-thickness',
89
- 'unicode-bidi',
90
- 'unicode-range',
91
- 'units-per-em',
92
- 'v-alphabetic',
93
- 'v-hanging',
94
- 'v-ideographic',
95
- 'v-mathematical',
96
- 'vector-effect',
97
- 'vert-adv-y',
98
- 'vert-origin-x',
99
- 'vert-origin-y',
100
- 'word-spacing',
101
- 'writing-mode',
102
- 'x-height',
103
- 'xlink:actuate',
104
- 'xlink:arcrole',
105
- 'xlink:href',
106
- 'xlink:role',
107
- 'xlink:show',
108
- 'xlink:title',
109
- 'xlink:type',
110
- 'xml:base',
111
- 'xmlns:xlink',
112
- 'xml:lang',
113
- 'xml:space',
114
-];
115
-
116
-var SVGDOMPropertyConfig = {
117
- Properties: {
118
- autoReverse: HAS_STRING_BOOLEAN_VALUE,
119
- externalResourcesRequired: HAS_STRING_BOOLEAN_VALUE,
120
- preserveAlpha: HAS_STRING_BOOLEAN_VALUE,
121
- },
122
- DOMAttributeNames: {
123
- autoReverse: 'autoReverse',
124
- externalResourcesRequired: 'externalResourcesRequired',
125
- preserveAlpha: 'preserveAlpha',
126
- },
127
- DOMAttributeNamespaces: {
128
- xlinkActuate: NS.xlink,
129
- xlinkArcrole: NS.xlink,
130
- xlinkHref: NS.xlink,
131
- xlinkRole: NS.xlink,
132
- xlinkShow: NS.xlink,
133
- xlinkTitle: NS.xlink,
134
- xlinkType: NS.xlink,
135
- xmlBase: NS.xml,
136
- xmlLang: NS.xml,
137
- xmlSpace: NS.xml,
138
- },
139
-};
140
-
141
-var CAMELIZE = /[\-\:]([a-z])/g;
142
-var capitalize = token => token[1].toUpperCase();
143
-
144
-ATTRS.forEach(original => {
145
- var reactName = original.replace(CAMELIZE, capitalize);
146
-
147
- SVGDOMPropertyConfig.Properties[reactName] = 0;
148
- SVGDOMPropertyConfig.DOMAttributeNames[reactName] = original;
149
-});
150
-
151
-export default SVGDOMPropertyConfig;