Skip to content

Commit

Permalink
Keep case of sass exports (#70)
Browse files Browse the repository at this point in the history
  • Loading branch information
zewish committed Feb 8, 2023
1 parent 8e158d0 commit dbb53a2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
2 changes: 2 additions & 0 deletions objectifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ function process(node) {
} else if (child.type === 'decl') {
if (child.prop[0] === '-' && child.prop[1] === '-') {
name = child.prop
} else if (child.parent && child.parent.selector === ':export') {
name = child.prop
} else {
name = camelcase(child.prop)
}
Expand Down
15 changes: 15 additions & 0 deletions test/objectifier.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,21 @@ test('converts declarations to camel case', () => {
})
})

test('preserves case for sass exported variables', () => {
let root = parse(
':export { caseSensitiveOne: 1px }' +
':export { caseSensitiveTwo: 2px }' +
':export { caseSensitiveThree: 3px }'
)
equal(postcssJS.objectify(root), {
':export': {
caseSensitiveOne: '1px',
caseSensitiveTwo: '2px',
caseSensitiveThree: '3px'
}
})
})

test('maintains !important declarations', () => {
let root = parse('margin-bottom: 0 !important')
equal(postcssJS.objectify(root), {
Expand Down

0 comments on commit dbb53a2

Please sign in to comment.