Skip to content

Commit e917e8f

Browse files
committed
Fix incorrect behaviour if hasBlock was set to false in extended at-rule object
1 parent a761d18 commit e917e8f

File tree

3 files changed

+115
-1
lines changed

3 files changed

+115
-1
lines changed

__tests__/order.js

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,3 +458,113 @@ groupTest([
458458
],
459459
},
460460
]);
461+
462+
groupTest([
463+
{
464+
options: {
465+
order: [
466+
{
467+
type: 'at-rule',
468+
hasBlock: false,
469+
},
470+
'declarations',
471+
],
472+
},
473+
cases: [
474+
{
475+
description: `doesn't change`,
476+
fixture: `
477+
a {
478+
@include hello;
479+
display: none;
480+
@include hello {
481+
display: block;
482+
}
483+
}
484+
`,
485+
expected: `
486+
a {
487+
@include hello;
488+
display: none;
489+
@include hello {
490+
display: block;
491+
}
492+
}
493+
`,
494+
},
495+
{
496+
description: `doesn't change`,
497+
fixture: `
498+
a {
499+
display: none;
500+
@include hello {
501+
display: block;
502+
}
503+
}
504+
`,
505+
expected: `
506+
a {
507+
display: none;
508+
@include hello {
509+
display: block;
510+
}
511+
}
512+
`,
513+
},
514+
{
515+
fixture: `
516+
a {
517+
display: none;
518+
@include hello;
519+
}
520+
`,
521+
expected: `
522+
a {
523+
@include hello;
524+
display: none;
525+
}
526+
`,
527+
},
528+
{
529+
fixture: `
530+
a {
531+
@include hello;
532+
@include hello {
533+
display: block;
534+
}
535+
display: none;
536+
}
537+
`,
538+
expected: `
539+
a {
540+
@include hello;
541+
display: none;
542+
@include hello {
543+
display: block;
544+
}
545+
}
546+
`,
547+
},
548+
{
549+
fixture: `
550+
a {
551+
@include hello {
552+
display: block;
553+
}
554+
@include hello;
555+
display: none;
556+
}
557+
`,
558+
expected: `
559+
a {
560+
@include hello;
561+
display: none;
562+
@include hello {
563+
display: block;
564+
}
565+
}
566+
`,
567+
},
568+
],
569+
},
570+
]);

__tests__/validate-options.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ testConfig({
7878
type: 'at-rule',
7979
hasBlock: true,
8080
},
81+
{
82+
type: 'at-rule',
83+
hasBlock: false,
84+
},
8185
{
8286
type: 'at-rule',
8387
},

lib/createExpectedOrder.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ module.exports = function createExpectedOrder(input) {
8282
}
8383
}
8484

85-
if (item.hasBlock) {
85+
if (!_.isUndefined(item.hasBlock)) {
8686
nodeData.hasBlock = item.hasBlock;
8787
}
8888

0 commit comments

Comments
 (0)