diff --git a/packages/react-native-web/src/exports/UIManager/index.js b/packages/react-native-web/src/exports/UIManager/index.js index 6d13ab7c..7e4f35d2 100644 --- a/packages/react-native-web/src/exports/UIManager/index.js +++ b/packages/react-native-web/src/exports/UIManager/index.js @@ -8,7 +8,7 @@ */ import getBoundingClientRect from '../../modules/getBoundingClientRect'; -import setValueForStyles from '../../vendor/react-dom/setValueForStyles'; +import setValueForStyles from '../../modules/setValueForStyles'; const getRect = node => { // Unlike the DOM's getBoundingClientRect, React Native layout measurements diff --git a/packages/react-native-web/src/vendor/react-dom/dangerousStyleValue/index.js b/packages/react-native-web/src/modules/setValueForStyles/dangerousStyleValue.js similarity index 96% rename from packages/react-native-web/src/vendor/react-dom/dangerousStyleValue/index.js rename to packages/react-native-web/src/modules/setValueForStyles/dangerousStyleValue.js index 0728ebab..eaefa9eb 100644 --- a/packages/react-native-web/src/vendor/react-dom/dangerousStyleValue/index.js +++ b/packages/react-native-web/src/modules/setValueForStyles/dangerousStyleValue.js @@ -10,7 +10,7 @@ * @noflow */ -import isUnitlessNumber from '../../../modules/unitlessNumbers'; +import isUnitlessNumber from '../unitlessNumbers'; /** * Convert a value into the proper css writable value. The style name `name` diff --git a/packages/react-native-web/src/vendor/react-dom/setValueForStyles/index.js b/packages/react-native-web/src/modules/setValueForStyles/index.js similarity index 94% rename from packages/react-native-web/src/vendor/react-dom/setValueForStyles/index.js rename to packages/react-native-web/src/modules/setValueForStyles/index.js index 2190e394..49c40f44 100644 --- a/packages/react-native-web/src/vendor/react-dom/setValueForStyles/index.js +++ b/packages/react-native-web/src/modules/setValueForStyles/index.js @@ -10,7 +10,7 @@ * @noflow */ -import dangerousStyleValue from '../dangerousStyleValue'; +import dangerousStyleValue from './dangerousStyleValue'; /** * Sets the value for multiple styles on a node. If a value is specified as diff --git a/packages/react-native-web/src/vendor/react-dom/warnValidStyle/index.js b/packages/react-native-web/src/vendor/react-dom/warnValidStyle/index.js deleted file mode 100644 index 623ee513..00000000 --- a/packages/react-native-web/src/vendor/react-dom/warnValidStyle/index.js +++ /dev/null @@ -1,167 +0,0 @@ -/* eslint-disable */ - -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * From React 16.0.0 - * @noflow - */ - -var emptyFunction = require('fbjs/lib/emptyFunction'); - -var warnValidStyle = emptyFunction; - -if (process.env.NODE_ENV !== 'production') { - var camelizeStyleName = require('fbjs/lib/camelizeStyleName'); - var warning = require('fbjs/lib/warning'); - - function getComponentName(instanceOrFiber) { - if (typeof instanceOrFiber.getName === 'function') { - // Stack reconciler - const instance = ((instanceOrFiber: any): ReactInstance); - return instance.getName(); - } - if (typeof instanceOrFiber.tag === 'number') { - // Fiber reconciler - const fiber = ((instanceOrFiber: any): Fiber); - const { type } = fiber; - if (typeof type === 'string') { - return type; - } - if (typeof type === 'function') { - return type.displayName || type.name; - } - } - return null; - } - - // 'msTransform' is correct, but the other prefixes should be capitalized - var badVendoredStyleNamePattern = /^(?:webkit|moz|o)[A-Z]/; - - // style values shouldn't contain a semicolon - var badStyleValueWithSemicolonPattern = /;\s*$/; - - var warnedStyleNames = {}; - var warnedStyleValues = {}; - var warnedForNaNValue = false; - var warnedForInfinityValue = false; - - var warnHyphenatedStyleName = function(name, owner) { - if (warnedStyleNames.hasOwnProperty(name) && warnedStyleNames[name]) { - return; - } - - warnedStyleNames[name] = true; - warning( - false, - 'Unsupported style property %s. Did you mean %s?%s', - name, - camelizeStyleName(name), - checkRenderMessage(owner) - ); - }; - - var warnBadVendoredStyleName = function(name, owner) { - if (warnedStyleNames.hasOwnProperty(name) && warnedStyleNames[name]) { - return; - } - - warnedStyleNames[name] = true; - warning( - false, - 'Unsupported vendor-prefixed style property %s. Did you mean %s?%s', - name, - name.charAt(0).toUpperCase() + name.slice(1), - checkRenderMessage(owner) - ); - }; - - var warnStyleValueWithSemicolon = function(name, value, owner) { - if (warnedStyleValues.hasOwnProperty(value) && warnedStyleValues[value]) { - return; - } - - warnedStyleValues[value] = true; - warning( - false, - "Style property values shouldn't contain a semicolon.%s " + 'Try "%s: %s" instead.', - checkRenderMessage(owner), - name, - value.replace(badStyleValueWithSemicolonPattern, '') - ); - }; - - var warnStyleValueIsNaN = function(name, value, owner) { - if (warnedForNaNValue) { - return; - } - - warnedForNaNValue = true; - warning( - false, - '`NaN` is an invalid value for the `%s` css style property.%s', - name, - checkRenderMessage(owner) - ); - }; - - var warnStyleValueIsInfinity = function(name, value, owner) { - if (warnedForInfinityValue) { - return; - } - - warnedForInfinityValue = true; - warning( - false, - '`Infinity` is an invalid value for the `%s` css style property.%s', - name, - checkRenderMessage(owner) - ); - }; - - var checkRenderMessage = function(owner) { - var ownerName; - if (owner != null) { - // Stack passes the owner manually all the way to CSSPropertyOperations. - ownerName = getComponentName(owner); - } else { - // Fiber doesn't pass it but uses ReactDebugCurrentFiber to track it. - // It is only enabled in development and tracks host components too. - // var {getCurrentFiberOwnerName} = require('ReactDebugCurrentFiber'); - // ownerName = getCurrentFiberOwnerName(); - // TODO: also report the stack. - } - if (ownerName) { - return '\n\nCheck the render method of `' + ownerName + '`.'; - } - return ''; - }; - - warnValidStyle = function(name, value, component) { - var owner; - if (component) { - // TODO: this only works with Stack. Seems like we need to add unit tests? - // owner = component._currentElement._owner; - } - if (name.indexOf('-') > -1) { - warnHyphenatedStyleName(name, owner); - } else if (badVendoredStyleNamePattern.test(name)) { - warnBadVendoredStyleName(name, owner); - } else if (badStyleValueWithSemicolonPattern.test(value)) { - warnStyleValueWithSemicolon(name, value, owner); - } - - if (typeof value === 'number') { - if (isNaN(value)) { - warnStyleValueIsNaN(name, value, owner); - } else if (!isFinite(value)) { - warnStyleValueIsInfinity(name, value, owner); - } - } - }; -} - -export default warnValidStyle;