Skip to content

Commit

Permalink
fix(css-to-react-native): propertyValue remove !import (NervJS#11870)
Browse files Browse the repository at this point in the history
Co-authored-by: tony chen <329604487@qq.com>
  • Loading branch information
2 people authored and yuconora committed Jun 14, 2022
1 parent fb82398 commit a994bbe
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
14 changes: 14 additions & 0 deletions packages/css-to-react-native/__tests__/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(`
Expand Down
4 changes: 4 additions & 0 deletions packages/css-to-react-native/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a994bbe

Please sign in to comment.