Skip to content

Commit

Permalink
fix: sizing polyfill
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathantneal committed Jul 30, 2021
1 parent 523e1b3 commit ce8e61e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/core/src/convert/toSizingValue.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { toHyphenCase } from './toHyphenCase.js'

/** Returns a declaration sizing value with polyfilled sizing keywords. */
export const toSizingValue = (/** @type {string} */ declarationName, /** @type {string} */ declarationValue) => (
declarationName in sizeProps && typeof declarationValue === 'string'
Expand All @@ -6,8 +8,8 @@ export const toSizingValue = (/** @type {string} */ declarationName, /** @type {
(data, lead, main, tail) => (
lead + (
main === 'stretch'
? `-moz-available${tail};${declarationName}:${lead}-webkit-fill-available`
: `-moz-fit-content${tail};${declarationName}:${lead}fit-content`
? `-moz-available${tail};${toHyphenCase(declarationName)}:${lead}-webkit-fill-available`
: `-moz-fit-content${tail};${toHyphenCase(declarationName)}:${lead}fit-content`
) + tail
),
)
Expand Down
20 changes: 20 additions & 0 deletions packages/core/tests/issue-655.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { createStitches } from '../src/index.js'

describe('Issue #655', () => {
test('Applying both variants from the one default variant', () => {
const { css, getCssText } = createStitches()

css({
maxWidth: 'fit-content',
minWidth: 'fit-content',
})()

expect(getCssText()).toBe(
`--stitches{--:2 c-dAAqmb}` +
`@media{.c-dAAqmb{` +
`max-width:-moz-fit-content;max-width:fit-content;` +
`min-width:-moz-fit-content;min-width:fit-content` +
`}}`
)
})
})

0 comments on commit ce8e61e

Please sign in to comment.