Skip to content

Commit 6b8e8f5

Browse files
committed
Fix multi value in stringifyImportant options
1 parent 157f848 commit 6b8e8f5

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

objectifier.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ function process(node, options = {}) {
5454
if (result[child.selector]) {
5555
for (let i in body) {
5656
let object = result[child.selector];
57-
if (stringifyImportant && object[i] && object[i].endsWith('!important')) {
58-
if (body[i].endsWith('!important')) {
57+
if (stringifyImportant && typeof object[i] === "string" && object[i].endsWith('!important')) {
58+
if (typeof body[i] === "string" && body[i].endsWith('!important')) {
5959
object[i] = body[i]
6060
}
6161
} else {

test/objectifier.test.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,5 +184,22 @@ test('keeps last important with priority', () => {
184184
})
185185
})
186186

187+
test('keeps last important with priority', () => {
188+
let root = parse('a { vertical-align: 2px center; };a { vertical-align: 1px center; }')
189+
equal(postcssJS.objectify(root, { stringifyImportant: true }), {
190+
a: {
191+
'verticalAlign': "1px center"
192+
}
193+
})
194+
})
195+
196+
test('keeps last important with priority', () => {
197+
let root = parse('a { vertical-align: 2px center !important; };a { vertical-align: 1px center; }')
198+
equal(postcssJS.objectify(root, { stringifyImportant: true }), {
199+
a: {
200+
'verticalAlign': "2px center !important"
201+
}
202+
})
203+
})
187204

188205
test.run()

0 commit comments

Comments
 (0)