mirror of
https://github.com/zhigang1992/react-native-web.git
synced 2026-04-08 22:42:58 +08:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
11d23f850a | ||
|
|
d994a25017 | ||
|
|
756df70154 | ||
|
|
f0b06419f9 | ||
|
|
60ff75705e |
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "react-native-web",
|
||||
"version": "0.0.89",
|
||||
"version": "0.0.91",
|
||||
"description": "React Native for Web",
|
||||
"main": "dist/index.js",
|
||||
"files": [
|
||||
|
||||
@@ -7,7 +7,7 @@ import flattenArray from '../../modules/flattenArray';
|
||||
import flattenStyle from './flattenStyle';
|
||||
import I18nManager from '../I18nManager';
|
||||
import mapKeyValue from '../../modules/mapKeyValue';
|
||||
import prefixInlineStyles from './prefixInlineStyles';
|
||||
import { prefixInlineStyles } from '../../modules/prefixStyles';
|
||||
import ReactNativePropRegistry from '../../modules/ReactNativePropRegistry';
|
||||
import StyleManager from './StyleManager';
|
||||
|
||||
|
||||
@@ -3,7 +3,18 @@
|
||||
import resolveTransform from '../resolveTransform';
|
||||
|
||||
describe('apis/StyleSheet/resolveTransform', () => {
|
||||
test('transform', () => {
|
||||
// passthrough if transform value is ever a string
|
||||
test('transform string', () => {
|
||||
const resolvedStyle = {};
|
||||
const transform = 'perspective(50px) scaleX(20) translateX(20px) rotate(20deg)';
|
||||
|
||||
const style = { transform };
|
||||
resolveTransform(resolvedStyle, style);
|
||||
|
||||
expect(resolvedStyle).toEqual({ transform });
|
||||
});
|
||||
|
||||
test('transform array', () => {
|
||||
const resolvedStyle = {};
|
||||
const style = {
|
||||
transform: [{ perspective: 50 }, { scaleX: 20 }, { translateX: 20 }, { rotate: '20deg' }]
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import hyphenateStyleName from 'hyphenate-style-name';
|
||||
import mapKeyValue from '../../modules/mapKeyValue';
|
||||
import normalizeValue from './normalizeValue';
|
||||
import prefixAll from 'inline-style-prefixer/static';
|
||||
import prefixStyles from '../../modules/prefixStyles';
|
||||
|
||||
const createDeclarationString = (prop, val) => {
|
||||
const name = hyphenateStyleName(prop);
|
||||
@@ -19,6 +19,6 @@ const createDeclarationString = (prop, val) => {
|
||||
* // => 'color:blue;width:20px'
|
||||
*/
|
||||
const generateCss = style =>
|
||||
mapKeyValue(prefixAll(style), createDeclarationString).sort().join(';');
|
||||
mapKeyValue(prefixStyles(style), createDeclarationString).sort().join(';');
|
||||
|
||||
module.exports = generateCss;
|
||||
|
||||
@@ -71,15 +71,17 @@ const i18nStyle = originalStyle => {
|
||||
continue;
|
||||
}
|
||||
|
||||
const value = style[prop];
|
||||
|
||||
if (PROPERTIES_TO_SWAP[prop]) {
|
||||
const newProp = flipProperty(prop);
|
||||
nextStyle[newProp] = style[prop];
|
||||
nextStyle[newProp] = value;
|
||||
} else if (PROPERTIES_SWAP_LEFT_RIGHT[prop]) {
|
||||
nextStyle[prop] = swapLeftRight(style[prop]);
|
||||
nextStyle[prop] = swapLeftRight(value);
|
||||
} else if (prop === 'textShadowOffset') {
|
||||
nextStyle[prop] = style[prop];
|
||||
nextStyle[prop].width = additiveInverse(style[prop].width);
|
||||
} else if (prop === 'transform') {
|
||||
nextStyle[prop] = value;
|
||||
nextStyle[prop].width = additiveInverse(value.width);
|
||||
} else if (prop === 'transform' && Array.isArray(value)) {
|
||||
nextStyle[prop] = style[prop].map(flipTransform);
|
||||
} else {
|
||||
nextStyle[prop] = style[prop];
|
||||
|
||||
@@ -15,13 +15,13 @@ const convertTransformMatrix = transformMatrix => {
|
||||
};
|
||||
|
||||
const resolveTransform = (resolvedStyle, style) => {
|
||||
let transform = style.transform;
|
||||
if (Array.isArray(style.transform)) {
|
||||
const transform = style.transform.map(mapTransform).join(' ');
|
||||
resolvedStyle.transform = transform;
|
||||
transform = style.transform.map(mapTransform).join(' ');
|
||||
} else if (style.transformMatrix) {
|
||||
const transform = convertTransformMatrix(style.transformMatrix);
|
||||
resolvedStyle.transform = transform;
|
||||
transform = convertTransformMatrix(style.transformMatrix);
|
||||
}
|
||||
resolvedStyle.transform = transform;
|
||||
};
|
||||
|
||||
module.exports = resolveTransform;
|
||||
|
||||
@@ -71,6 +71,9 @@ const NativeMethodsMixin = {
|
||||
const node = findNodeHandle(this);
|
||||
const classList = Array.prototype.slice.call(node.classList);
|
||||
const style = { ...node.style };
|
||||
// See #454
|
||||
delete style.length;
|
||||
|
||||
const domStyleProps = { classList, style };
|
||||
|
||||
// Next DOM state
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/* eslint-env jasmine, jest */
|
||||
|
||||
import prefixInlineStyles from '../prefixInlineStyles';
|
||||
import { prefixInlineStyles } from '..';
|
||||
|
||||
describe('apis/StyleSheet/prefixInlineStyles', () => {
|
||||
test('handles array values', () => {
|
||||
describe('modules/prefixStyles', () => {
|
||||
test('handles array values for inline styles', () => {
|
||||
const style = {
|
||||
display: ['-webkit-flex', 'flex']
|
||||
};
|
||||
@@ -1,6 +1,8 @@
|
||||
import prefixAll from 'inline-style-prefixer/static';
|
||||
|
||||
const prefixInlineStyles = style => {
|
||||
export default prefixAll;
|
||||
|
||||
export const prefixInlineStyles = style => {
|
||||
const prefixedStyles = prefixAll(style);
|
||||
|
||||
// React@15 removed undocumented support for fallback values in
|
||||
@@ -14,5 +16,3 @@ const prefixInlineStyles = style => {
|
||||
|
||||
return prefixedStyles;
|
||||
};
|
||||
|
||||
module.exports = prefixInlineStyles;
|
||||
Reference in New Issue
Block a user