diff --git a/packages/uniwind/src/metro/addMetaToStylesTemplate.ts b/packages/uniwind/src/metro/addMetaToStylesTemplate.ts index 2a7de792..2f38636c 100644 --- a/packages/uniwind/src/metro/addMetaToStylesTemplate.ts +++ b/packages/uniwind/src/metro/addMetaToStylesTemplate.ts @@ -126,7 +126,7 @@ export const addMetaToStylesTemplate = (Processor: ProcessorBuilder, currentPlat focus, disabled, importantProperties: importantProperties - ?.map(property => property.startsWith('--') ? property : toCamelCase) + ?.map(property => property.startsWith('--') ? property : toCamelCase(property)) .map(makeSafeForSerialization) ?? [], dataAttributes, complexity: [ diff --git a/packages/uniwind/tests/native/styles-parsing/specificity.test.tsx b/packages/uniwind/tests/native/styles-parsing/specificity.test.tsx new file mode 100644 index 00000000..36ce85c8 --- /dev/null +++ b/packages/uniwind/tests/native/styles-parsing/specificity.test.tsx @@ -0,0 +1,41 @@ +import * as React from 'react' +import View from '../../../src/components/native/View' +import { TW_BLUE_500, TW_GREEN_500, TW_RED_500 } from '../../consts' +import { renderUniwind } from '../utils' + +describe('Specificity', () => { + test('Important', () => { + const { getStylesFromId } = renderUniwind( + + + + + + + , + ) + + expect(getStylesFromId('no-important').color).toBe(TW_BLUE_500) + /* NOTE: when both classes are !important, the first one wins. + This diverges from CSS where the last !important would win. */ + expect(getStylesFromId('both-important').color).toBe(TW_RED_500) + expect(getStylesFromId('important-first').color).toBe(TW_RED_500) + expect(getStylesFromId('important-middle').color).toBe(TW_GREEN_500) + expect(getStylesFromId('important-last').color).toBe(TW_BLUE_500) + }) +})