Skip to content

Commit 08e8cc9

Browse files
Move lib/DOMPropertyConfig.js to lib/property-config.js
Tidy and refactor code.
1 parent b809226 commit 08e8cc9

File tree

3 files changed

+24
-34
lines changed

3 files changed

+24
-34
lines changed

lib/DOMPropertyConfig.js

Lines changed: 0 additions & 25 deletions
This file was deleted.

lib/attributes-to-props.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
/**
44
* Module dependencies.
55
*/
6-
var HTMLDOMPropertyConfig = require('./DOMPropertyConfig').HTMLDOMPropertyConfig;
76
var utilities = require('./utilities');
87
var propertyConfig = require('./property-config');
8+
var config = propertyConfig.config;
9+
var isCustomAttribute = propertyConfig.HTMLDOMPropertyConfig.isCustomAttribute;
910

1011
/**
1112
* Make attributes compatible with React props.
@@ -24,20 +25,20 @@ function attributesToProps(attributes) {
2425
propertyValue = attributes[propertyName];
2526

2627
// custom attributes (`data-` and `aria-`)
27-
if (HTMLDOMPropertyConfig.isCustomAttribute(propertyName)) {
28+
if (isCustomAttribute(propertyName)) {
2829
props[propertyName] = propertyValue;
2930
continue;
3031
}
3132

3233
// make HTML DOM attribute/property consistent with React attribute/property
33-
reactProperty = propertyConfig.html[propertyName.toLowerCase()];
34+
reactProperty = config.html[propertyName.toLowerCase()];
3435
if (reactProperty) {
3536
props[reactProperty] = propertyValue;
3637
continue;
3738
}
3839

3940
// make SVG DOM attribute/property consistent with React attribute/property
40-
reactProperty = propertyConfig.svg[propertyName];
41+
reactProperty = config.svg[propertyName];
4142
if (reactProperty) {
4243
props[reactProperty] = propertyValue;
4344
}

lib/property-config.js

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,19 @@
44
* Module dependencies.
55
*/
66
var utilities = require('./utilities');
7-
var DOMPropertyConfig = require('./DOMPropertyConfig');
8-
var HTMLDOMPropertyConfig = DOMPropertyConfig.HTMLDOMPropertyConfig;
9-
var SVGDOMPropertyConfig = DOMPropertyConfig.SVGDOMPropertyConfig;
7+
8+
// HTML and SVG DOM Property Configs
9+
// originally in `react/lib/` but moved to `react-dom/lib/` in 15.4
10+
var HTMLDOMPropertyConfig;
11+
var SVGDOMPropertyConfig;
12+
13+
try {
14+
HTMLDOMPropertyConfig = require('react-dom/lib/HTMLDOMPropertyConfig');
15+
SVGDOMPropertyConfig = require('react-dom/lib/SVGDOMPropertyConfig');
16+
} catch (error) {
17+
HTMLDOMPropertyConfig = require('react/lib/HTMLDOMPropertyConfig');
18+
SVGDOMPropertyConfig = require('react/lib/SVGDOMPropertyConfig');
19+
}
1020

1121
var config = {
1222
html: {},
@@ -54,6 +64,10 @@ for (propertyName in SVGDOMPropertyConfig.Properties) {
5464
}
5565

5666
/**
57-
* Export React property config.
67+
* Export React property configs.
5868
*/
59-
module.exports = config;
69+
module.exports = {
70+
config: config,
71+
HTMLDOMPropertyConfig: HTMLDOMPropertyConfig,
72+
SVGDOMPropertyConfig: SVGDOMPropertyConfig
73+
};

0 commit comments

Comments
 (0)