Skip to content
This repository has been archived by the owner on Feb 23, 2022. It is now read-only.

Expand MergeAdjacentRulesetNodesWithSameDeclarations functionality to any repetitive rulesets #129

Open
adam-rocska opened this issue Jul 1, 2018 · 0 comments

Comments

@adam-rocska
Copy link

adam-rocska commented Jul 1, 2018

Summary

AS A Software Engineer
I WOULD LIKE TO have rulesets belonging to the same selectors merged across multiple GSS files
SO THAT I may have a more efficient and smaller CSS file as a result.

Description

At the time of writing, rulesets belonging to the same selector are only merged, if they are consecutive to one another / adjacent to one another.
I would like to have this behaviour expanded in a way, that rulesets belonging to the same selector are also merged if they are at different parts of the same GSS file, or are in the different parts of multiple GSS files.

Current Behaviour

Same File ; Consecutive rulesets ; Rulesets are merged

GIVEN I have the following CSS rulesets in the same GSS file :

/* ... */
body {
   background-color : #f00;
}
body {
   padding : 13px;
}
/* ... */

WHEN I perform a compilation gss my.gss
THEN I receive the following output:

/* ... */
body {
   background-color : #f00;
   padding : 13px;
}
/* ... */

Separate, but consecutive / adjacent files ; Consecutive rulesets ; Rulesets are merged

GIVEN I have the following CSS ruleset in first.gss

/* ... */
body {
   background-color : #f00;
}

AND the following css ruleset in second.gss

body {
   padding : 13px;
}
/* ... */

WHEN I perform a compilation gss first.gss second.gss
THEN I receive the following output:

/* ... */
body {
   background-color : #f00;
   padding : 13px;
}
/* ... */

Same File ; Ruleset in between ; Rulesets are NOT merged

GIVEN I have the following CSS rulesets in the same GSS file :

/* ... */
body {
   background-color : #f00;
}
div {
   cursor : pointer;
}
body {
   padding : 13px;
}
/* ... */

WHEN I perform a compilation gss my.gss
THEN I receive the following output:

/* ... */
body {
   background-color : #f00;
}
div {
   cursor : pointer;
}
body {
   padding : 13px;
}
/* ... */

Separate, but consecutive / adjacent files ; Ruleset in between ; Rulesets are NOT merged

GIVEN I have the following CSS ruleset in first.gss

/* ... */
body {
   background-color : #f00;
}
div {
   cursor : pointer;
}

AND the following css ruleset in second.gss

body {
   padding : 13px;
}
/* ... */

WHEN I perform a compilation gss first.gss second.gss
THEN I receive the following output:

/* ... */
body {
   background-color : #f00;
}
div {
   cursor : pointer;
}
body {
   padding : 13px;
}
/* ... */

Expected Behaviour

Same File ; Ruleset in between ; Rulesets ARE merged

GIVEN I have the following CSS rulesets in the same GSS file :

/* ... */
body {
   background-color : #f00;
}
div {
   cursor : pointer;
}
body {
   padding : 13px;
}
/* ... */

WHEN I perform a compilation gss my.gss
THEN I receive the following output:

/* ... */
body {
   background-color : #f00;
   padding : 13px;
}
div {
   cursor : pointer;
}
/* ... */

Separate, but consecutive / adjacent files ; Ruleset in between ; Rulesets ARE merged

GIVEN I have the following CSS ruleset in first.gss

/* ... */
body {
   background-color : #f00;
}
div {
   cursor : pointer;
}

AND the following css ruleset in second.gss

body {
   padding : 13px;
}
/* ... */

WHEN I perform a compilation gss first.gss second.gss
THEN I receive the following output:

/* ... */
body {
   background-color : #f00;
   padding : 13px;
}
div {
   cursor : pointer;
}
/* ... */

Additional Comments

I would be more than happy to perform a contribution to the project by implementing this behaviour. As far as I could tell by an initial mediocre inspection, this feature could relatively easily be delivered by an outsider based on the implementation of MergeAdjacentRulesetNodesWithSameDeclarations .

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant