Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion modules/__tests__/createPrefixer-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,16 @@ describe('Static Prefixer', () => {
expect(prefix(input)).toEqual(output)
})

it('should expand the shorthand column syntax with span', () => {
const input = { gridColumn: '3 / span 1' }
const output = {
gridColumn: '3 / span 1',
msGridColumn: 3,
msGridColumnSpan: 1,
}
expect(prefix(input)).toEqual(output)
})

it('should expand the shorthand row syntax', () => {
const input = { gridRow: '2 / 7' }
const output = {
Expand All @@ -536,11 +546,12 @@ describe('Static Prefixer', () => {
expect(prefix(input)).toEqual(output)
})

it('should not expand non-numerical values', () => {
it('should expand the shorthand row syntax with span', () => {
const input = { gridRow: '2 / span 3' }
const output = {
gridRow: '2 / span 3',
msGridRow: 2,
msGridRowSpan: 3,
}
expect(prefix(input)).toEqual(output)
})
Expand Down
24 changes: 18 additions & 6 deletions modules/plugins/grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,15 @@ const propertyConverters = {
if (isSimplePositionValue(value)) {
style.msGridColumn = value
} else {
const [start, end] = value.split('/').map(position => +position)
propertyConverters.gridColumnStart(start, style)
propertyConverters.gridColumnEnd(end, style)
const [start, end] = value.split('/')
propertyConverters.gridColumnStart(+start, style)

const [maybeSpan, maybeNumber] = end.split(/ ?span /)
if (maybeSpan === '') {
propertyConverters.gridColumnEnd(+start + +maybeNumber, style)
} else {
propertyConverters.gridColumnEnd(+end, style)
}
}
},

Expand All @@ -45,9 +51,15 @@ const propertyConverters = {
if (isSimplePositionValue(value)) {
style.msGridRow = value
} else {
const [start, end] = value.split('/').map(position => +position)
propertyConverters.gridRowStart(start, style)
propertyConverters.gridRowEnd(end, style)
const [start, end] = value.split('/')
propertyConverters.gridRowStart(+start, style)

const [maybeSpan, maybeNumber] = end.split(/ ?span /)
if (maybeSpan === '') {
propertyConverters.gridRowEnd(+start + +maybeNumber, style)
} else {
propertyConverters.gridRowEnd(+end, style)
}
}
},

Expand Down