From b1cd92a65d98ae997f63daac4ebf45e893a6629f Mon Sep 17 00:00:00 2001 From: Nicolas Gallagher Date: Sun, 1 Jan 2017 18:35:18 -0800 Subject: [PATCH] [change] update Animated Fix #309 --- examples/.storybook/webpack.config.js | 5 ----- package.json | 2 +- src/apis/StyleSheet/injector.js | 8 +++----- src/modules/polyfills/Set.js | 8 -------- webpack.config.js | 5 ----- yarn.lock | 19 +++++++++---------- 6 files changed, 13 insertions(+), 34 deletions(-) delete mode 100644 src/modules/polyfills/Set.js diff --git a/examples/.storybook/webpack.config.js b/examples/.storybook/webpack.config.js index dbc85e36..3786b57b 100644 --- a/examples/.storybook/webpack.config.js +++ b/examples/.storybook/webpack.config.js @@ -24,11 +24,6 @@ module.exports = { 'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'development'), 'process.env.__REACT_NATIVE_DEBUG_ENABLED__': DEV }), - // https://github.com/animatedjs/animated/issues/40 - new webpack.NormalModuleReplacementPlugin( - /es6-set/, - path.join(__dirname, '../../src/modules/polyfills/Set.js') - ), new webpack.optimize.OccurenceOrderPlugin() ], resolve: { diff --git a/package.json b/package.json index 7823a2a6..d30cedf8 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "test:watch": "npm run test:jest -- --watch" }, "dependencies": { - "animated": "^0.1.3", + "animated": "^0.1.5", "array-find-index": "^1.0.2", "asap": "^2.0.5", "babel-runtime": "^6.11.6", diff --git a/src/apis/StyleSheet/injector.js b/src/apis/StyleSheet/injector.js index d661e353..74a66bb5 100644 --- a/src/apis/StyleSheet/injector.js +++ b/src/apis/StyleSheet/injector.js @@ -4,7 +4,6 @@ */ import asap from 'asap'; -import ExecutionEnvironment from 'fbjs/lib/ExecutionEnvironment'; const hasOwnProperty = Object.prototype.hasOwnProperty; @@ -27,7 +26,7 @@ const getStyleText = () => { // TODO: SSR support const getAvailableClassNames = () => { - if (ExecutionEnvironment.canUseDOM) { + if (global.document) { if (!styleNode) { styleNode = document.getElementById(STYLE_ELEMENT_ID); } @@ -45,8 +44,7 @@ const getAvailableClassNames = () => { const createStyleHTML = (text) => ``; const frame = () => { - if (!isDirty || !ExecutionEnvironment.canUseDOM) { return; } - + if (!isDirty || !global.document) { return; } isDirty = false; styleNode = styleNode || document.getElementById(STYLE_ELEMENT_ID); @@ -74,7 +72,7 @@ const addRule = (key, rule) => { registry[key] = rule; if (!isDirty) { isDirty = true; - if (ExecutionEnvironment.canUseDOM) { + if (global.document) { asap(frame); } } diff --git a/src/modules/polyfills/Set.js b/src/modules/polyfills/Set.js deleted file mode 100644 index 7b6a242a..00000000 --- a/src/modules/polyfills/Set.js +++ /dev/null @@ -1,8 +0,0 @@ -function SetPolyfill() { this._cache = []; } -SetPolyfill.prototype.add = function (e) { - if (this._cache.indexOf(e) === -1) { this._cache.push(e); } -}; -SetPolyfill.prototype.forEach = function (cb) { - this._cache.forEach(cb); -}; -module.exports = SetPolyfill; diff --git a/webpack.config.js b/webpack.config.js index e6aa4c08..dcff5266 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -31,11 +31,6 @@ module.exports = { }), new webpack.DefinePlugin({ 'process.env.NODE_ENV': JSON.stringify('production') }), new webpack.optimize.DedupePlugin(), - // https://github.com/animatedjs/animated/issues/40 - new webpack.NormalModuleReplacementPlugin( - /es6-set/, - path.join(__dirname, 'dist/modules/polyfills/Set.js') - ), new webpack.optimize.OccurenceOrderPlugin(), new webpack.optimize.UglifyJsPlugin({ compress: { diff --git a/yarn.lock b/yarn.lock index c34a879e..be8db9d0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -181,13 +181,12 @@ amdefine@>=0.0.4: version "1.0.1" resolved "https://registry.yarnpkg.com/amdefine/-/amdefine-1.0.1.tgz#4a5282ac164729e93619bcfd3ad151f817ce91f5" -animated@^0.1.3: - version "0.1.4" - resolved "https://registry.yarnpkg.com/animated/-/animated-0.1.4.tgz#1e7d119ea0027e1279b96ec309f5cb54935a915a" +animated@^0.1.5: + version "0.1.5" + resolved "https://registry.yarnpkg.com/animated/-/animated-0.1.5.tgz#83df8dc443d57abab7b0bb04818b0b655b31c9b9" dependencies: - es6-set "^0.1.4" invariant "^2.2.0" - tinycolor "0.0.1" + normalize-css-color "^1.0.1" ansi-escapes@^1.1.0, ansi-escapes@^1.4.0: version "1.4.0" @@ -2045,7 +2044,7 @@ es6-map@^0.1.3: es6-symbol "~3.1.0" event-emitter "~0.3.4" -es6-set@^0.1.4, es6-set@~0.1.3: +es6-set@~0.1.3: version "0.1.4" resolved "https://registry.yarnpkg.com/es6-set/-/es6-set-0.1.4.tgz#9516b6761c2964b92ff479456233a247dc707ce8" dependencies: @@ -4017,6 +4016,10 @@ nopt@3.x, nopt@~3.0.6: dependencies: abbrev "1" +normalize-css-color@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/normalize-css-color/-/normalize-css-color-1.0.1.tgz#792f59cae25036950a9127cfcfddc073048f4f9d" + normalize-package-data@^2.3.2, normalize-package-data@^2.3.4: version "2.3.5" resolved "https://registry.yarnpkg.com/normalize-package-data/-/normalize-package-data-2.3.5.tgz#8d924f142960e1777e7ffe170543631cc7cb02df" @@ -5452,10 +5455,6 @@ timers-browserify@^1.0.1: dependencies: process "~0.11.0" -tinycolor@0.0.1: - version "0.0.1" - resolved "https://registry.yarnpkg.com/tinycolor/-/tinycolor-0.0.1.tgz#320b5a52d83abb5978d81a3e887d4aefb15a6164" - tmpl@1.0.x: version "1.0.4" resolved "https://registry.yarnpkg.com/tmpl/-/tmpl-1.0.4.tgz#23640dd7b42d00433911140820e5cf440e521dd1"