Skip to content

Commit dbb53a2

Browse files
authored
Keep case of sass exports (#70)
1 parent 8e158d0 commit dbb53a2

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

objectifier.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ function process(node) {
6060
} else if (child.type === 'decl') {
6161
if (child.prop[0] === '-' && child.prop[1] === '-') {
6262
name = child.prop
63+
} else if (child.parent && child.parent.selector === ':export') {
64+
name = child.prop
6365
} else {
6466
name = camelcase(child.prop)
6567
}

test/objectifier.test.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,21 @@ test('converts declarations to camel case', () => {
4040
})
4141
})
4242

43+
test('preserves case for sass exported variables', () => {
44+
let root = parse(
45+
':export { caseSensitiveOne: 1px }' +
46+
':export { caseSensitiveTwo: 2px }' +
47+
':export { caseSensitiveThree: 3px }'
48+
)
49+
equal(postcssJS.objectify(root), {
50+
':export': {
51+
caseSensitiveOne: '1px',
52+
caseSensitiveTwo: '2px',
53+
caseSensitiveThree: '3px'
54+
}
55+
})
56+
})
57+
4358
test('maintains !important declarations', () => {
4459
let root = parse('margin-bottom: 0 !important')
4560
equal(postcssJS.objectify(root), {

0 commit comments

Comments
 (0)