From fd1d648ff2a4b3c05b84280068a02a2ca7937e62 Mon Sep 17 00:00:00 2001 From: shinken008 Date: Tue, 31 May 2022 23:15:11 +0800 Subject: [PATCH] fix(css-to-react-native): propertyValue remove !import --- .../css-to-react-native/__tests__/index.spec.js | 14 ++++++++++++++ packages/css-to-react-native/src/index.js | 4 ++++ 2 files changed, 18 insertions(+) diff --git a/packages/css-to-react-native/__tests__/index.spec.js b/packages/css-to-react-native/__tests__/index.spec.js index d7226cd69f81..f93d028314e4 100644 --- a/packages/css-to-react-native/__tests__/index.spec.js +++ b/packages/css-to-react-native/__tests__/index.spec.js @@ -3511,6 +3511,20 @@ describe('ICSS :export pseudo-selector', () => { }) }) + it('should transform propertyValue remove !import key', () => { + expect( + transform(` + .foo { + color: red !import; + } + `, { scalable: false }) + ).toEqual({ + foo: { + color: 'red' + } + }) + }) + it('should throw an error if exportedKey has the same name as a class and is defined twice', () => { expect(() => transform(` diff --git a/packages/css-to-react-native/src/index.js b/packages/css-to-react-native/src/index.js index 4c4c57de61cd..8fe72707eba8 100644 --- a/packages/css-to-react-native/src/index.js +++ b/packages/css-to-react-native/src/index.js @@ -59,6 +59,10 @@ const transformDecls = (styles, declarations, result, options = {}) => { ) { value = value.replace(/(\d+)px/g, '$1PX') } + // expect value is legal so that remove !import + if (/!import/i.test(value)) { + value = value.replace(/!import/, '') + } if (shorthandBorderProps.indexOf(property) > -1) { // transform single value shorthand border properties back to