Skip to content

Commit

Permalink
Fix bug since DOMPropertyConfigs are moved to react-dom in v15.4
Browse files Browse the repository at this point in the history
Both `HTMLDOMPropertyConfig.js` and `SVGDOMPropertyConfig.js` used
to be in `react/lib/` directory but since v15.4.x, the configs
have been moved to `react-dom/lib/`.

Created a module that tried to require either `react-dom/lib/`
or `react/lib/` (fallback).

A more permanent (less error-prone) solution may be to keep a
hardcopy of both configs in the repository (minimize coupling and
risk of another change from breaking the package).
  • Loading branch information
remarkablemark committed Nov 17, 2016
1 parent cc9c53e commit 3530cfa
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 3 deletions.
25 changes: 25 additions & 0 deletions lib/DOMPropertyConfig.js
@@ -0,0 +1,25 @@
'use strict';

/**
* Module dependencies.
*/
var HTMLDOMPropertyConfig;
var SVGDOMPropertyConfig;

// HTML and SVG DOM Property Config
// moved to `react-dom` in v15.4.x
try {
HTMLDOMPropertyConfig = require('react-dom/lib/HTMLDOMPropertyConfig');
SVGDOMPropertyConfig = require('react-dom/lib/SVGDOMPropertyConfig');
} catch (error) {
HTMLDOMPropertyConfig = require('react/lib/HTMLDOMPropertyConfig');
SVGDOMPropertyConfig = require('react/lib/SVGDOMPropertyConfig');
}

/**
* Export config.
*/
module.exports = {
HTMLDOMPropertyConfig: HTMLDOMPropertyConfig,
SVGDOMPropertyConfig: SVGDOMPropertyConfig
};
2 changes: 1 addition & 1 deletion lib/attributes-to-props.js
Expand Up @@ -3,7 +3,7 @@
/**
* Module dependencies.
*/
var HTMLDOMPropertyConfig = require('react/lib/HTMLDOMPropertyConfig');
var HTMLDOMPropertyConfig = require('./DOMPropertyConfig').HTMLDOMPropertyConfig;
var utilities = require('./utilities');
var propertyConfig = require('./property-config');

Expand Down
5 changes: 3 additions & 2 deletions lib/property-config.js
Expand Up @@ -4,8 +4,9 @@
* Module dependencies.
*/
var utilities = require('./utilities');
var HTMLDOMPropertyConfig = require('react/lib/HTMLDOMPropertyConfig');
var SVGDOMPropertyConfig = require('react/lib/SVGDOMPropertyConfig');
var DOMPropertyConfig = require('./DOMPropertyConfig');
var HTMLDOMPropertyConfig = DOMPropertyConfig.HTMLDOMPropertyConfig;
var SVGDOMPropertyConfig = DOMPropertyConfig.SVGDOMPropertyConfig;

var config = {
html: {},
Expand Down

0 comments on commit 3530cfa

Please sign in to comment.