Skip to content

Commit 653d2ff

Browse files
committed
[changed] deprecate domUtils as a public API
1 parent a6e5a9a commit 653d2ff

File tree

5 files changed

+35
-7
lines changed

5 files changed

+35
-7
lines changed

src/Affix.js

-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
import React from 'react';
22
import classNames from 'classnames';
33
import AffixMixin from './AffixMixin';
4-
import domUtils from './utils/domUtils';
54

65
const Affix = React.createClass({
7-
statics: {
8-
domUtils
9-
},
106

117
mixins: [AffixMixin],
128

src/index.js

+25-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import deprecationWarning from './utils/deprecationWarning';
2+
13
export Accordion from './Accordion';
24
export Affix from './Affix';
35
export AffixMixin from './AffixMixin';
@@ -70,16 +72,36 @@ export Fade from './Collapse';
7072

7173
export * as FormControls from './FormControls';
7274

75+
import domUtils from './utils/domUtils';
7376
import childrenValueInputValidation from './utils/childrenValueInputValidation';
7477
import createChainedFunction from './utils/createChainedFunction';
75-
import domUtils from './utils/domUtils';
7678
import ValidComponentChildren from './utils/ValidComponentChildren';
7779
import CustomPropTypes from './utils/CustomPropTypes';
7880

7981
export const utils = {
8082
childrenValueInputValidation,
8183
createChainedFunction,
82-
domUtils,
8384
ValidComponentChildren,
84-
CustomPropTypes
85+
CustomPropTypes,
86+
domUtils: createDeprecationWrapper(domUtils, 'utils/domUtils', 'npm install dom-helpers'),
8587
};
88+
89+
function createDeprecationWrapper(obj, deprecated, instead, link){
90+
let wrapper = {};
91+
92+
if (process.env.NODE_ENV === 'production'){
93+
return obj;
94+
}
95+
96+
Object.keys(obj).forEach(key => {
97+
Object.defineProperty(wrapper, key, {
98+
get(){
99+
deprecationWarning(deprecated, instead, link);
100+
return obj[key];
101+
},
102+
set(x){ obj[key] = x; }
103+
});
104+
});
105+
106+
return wrapper;
107+
}

src/utils/domUtils.js

+6
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ function ownerWindow(componentOrElement) {
2323
return getOwnerWindow(doc);
2424
}
2525

26+
//TODO remove in 0.26
27+
function getComputedStyles(elem) {
28+
return ownerDocument(elem).defaultView.getComputedStyle(elem, null);
29+
}
30+
2631
/**
2732
* Get an element's size
2833
*
@@ -45,6 +50,7 @@ function getSize(elem) {
4550
export default {
4651
canUseDom,
4752
css,
53+
getComputedStyles,
4854
contains,
4955
ownerWindow,
5056
ownerDocument,

src/utils/index.js

+3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ import deprecationWarning from './deprecationWarning';
22

33
export childrenValueInputValidation from './childrenValueInputValidation';
44
export createChainedFunction from './createChainedFunction';
5+
6+
deprecationWarning('utils/domUtils', 'npm install dom-helpers');
57
export domUtils from './domUtils';
8+
69
export ValidComponentChildren from './ValidComponentChildren';
710

811
deprecationWarning('utils/CustomPropTypes', 'npm install react-prop-types',

webpack/docs.config.js

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ if (options.debug) {
2121
}
2222

2323
export default _.extend({}, baseConfig, {
24+
2425
entry: {
2526
bundle: options.debug ? devEntryBundle : entryFile
2627
},

0 commit comments

Comments
 (0)