From 653d2ffa078b3a47ebfc54dad282fc5bfee6c86b Mon Sep 17 00:00:00 2001 From: jquense Date: Mon, 17 Aug 2015 08:32:49 -0400 Subject: [PATCH] [changed] deprecate domUtils as a public API --- src/Affix.js | 4 ---- src/index.js | 28 +++++++++++++++++++++++++--- src/utils/domUtils.js | 6 ++++++ src/utils/index.js | 3 +++ webpack/docs.config.js | 1 + 5 files changed, 35 insertions(+), 7 deletions(-) diff --git a/src/Affix.js b/src/Affix.js index 9648fa5166..117ee83cd3 100644 --- a/src/Affix.js +++ b/src/Affix.js @@ -1,12 +1,8 @@ import React from 'react'; import classNames from 'classnames'; import AffixMixin from './AffixMixin'; -import domUtils from './utils/domUtils'; const Affix = React.createClass({ - statics: { - domUtils - }, mixins: [AffixMixin], diff --git a/src/index.js b/src/index.js index 085bc9e392..85b611af11 100644 --- a/src/index.js +++ b/src/index.js @@ -1,3 +1,5 @@ +import deprecationWarning from './utils/deprecationWarning'; + export Accordion from './Accordion'; export Affix from './Affix'; export AffixMixin from './AffixMixin'; @@ -70,16 +72,36 @@ export Fade from './Collapse'; export * as FormControls from './FormControls'; +import domUtils from './utils/domUtils'; import childrenValueInputValidation from './utils/childrenValueInputValidation'; import createChainedFunction from './utils/createChainedFunction'; -import domUtils from './utils/domUtils'; import ValidComponentChildren from './utils/ValidComponentChildren'; import CustomPropTypes from './utils/CustomPropTypes'; export const utils = { childrenValueInputValidation, createChainedFunction, - domUtils, ValidComponentChildren, - CustomPropTypes + CustomPropTypes, + domUtils: createDeprecationWrapper(domUtils, 'utils/domUtils', 'npm install dom-helpers'), }; + +function createDeprecationWrapper(obj, deprecated, instead, link){ + let wrapper = {}; + + if (process.env.NODE_ENV === 'production'){ + return obj; + } + + Object.keys(obj).forEach(key => { + Object.defineProperty(wrapper, key, { + get(){ + deprecationWarning(deprecated, instead, link); + return obj[key]; + }, + set(x){ obj[key] = x; } + }); + }); + + return wrapper; +} diff --git a/src/utils/domUtils.js b/src/utils/domUtils.js index 1002669ac5..5ffd09db5f 100644 --- a/src/utils/domUtils.js +++ b/src/utils/domUtils.js @@ -23,6 +23,11 @@ function ownerWindow(componentOrElement) { return getOwnerWindow(doc); } +//TODO remove in 0.26 +function getComputedStyles(elem) { + return ownerDocument(elem).defaultView.getComputedStyle(elem, null); +} + /** * Get an element's size * @@ -45,6 +50,7 @@ function getSize(elem) { export default { canUseDom, css, + getComputedStyles, contains, ownerWindow, ownerDocument, diff --git a/src/utils/index.js b/src/utils/index.js index e0048ad683..e84c9f5b33 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -2,7 +2,10 @@ import deprecationWarning from './deprecationWarning'; export childrenValueInputValidation from './childrenValueInputValidation'; export createChainedFunction from './createChainedFunction'; + +deprecationWarning('utils/domUtils', 'npm install dom-helpers'); export domUtils from './domUtils'; + export ValidComponentChildren from './ValidComponentChildren'; deprecationWarning('utils/CustomPropTypes', 'npm install react-prop-types', diff --git a/webpack/docs.config.js b/webpack/docs.config.js index ceff28f49d..dcaaac01cb 100644 --- a/webpack/docs.config.js +++ b/webpack/docs.config.js @@ -21,6 +21,7 @@ if (options.debug) { } export default _.extend({}, baseConfig, { + entry: { bundle: options.debug ? devEntryBundle : entryFile },