csso icon indicating copy to clipboard operation
csso copied to clipboard

Fail restructuring similar blocks

Open silentroach opened this issue 10 years ago • 11 comments

Input:

.support-question .closed {
    background: url('/s/a/i/ic/util.gif') no-repeat transparent top right;
    background-position: right -65px;
    white-space: nowrap;
    padding-right: 15px;
}
.support-question .opened {
    background: url('/s/a/i/ic/util.gif') no-repeat transparent top right;
    background-position: right -450px;
    white-space: nowrap;
    padding-right: 15px;
}

After CSSO:

.support-question .closed {
    background-position:right -65px
}
.support-question .closed, .support-question .opened {
    background:url('/s/a/i/ic/util.gif') no-repeat top right;
    white-space:nowrap;
    padding-right:15px
}
.support-question .opened {
    background-position:right -450px
}

Position for closed is overriden with default values :{

silentroach avatar Mar 30 '14 12:03 silentroach

Something like this:

.pages {
    background-size: cover;
}
#slide-01 {
    background: url(lalala.png) no-repeat;
    background-size: cover;
}

output:

.pages, #slide-01{
    background-size:cover
}

#slide-01{
    background:url(lalala.png) no-repeat
}

background-size is overriden with default value

silentroach avatar May 06 '14 11:05 silentroach

Bye, csso

silentroach avatar Dec 05 '14 17:12 silentroach

@silentroach What are you using instead? This project looks quite dead.

magnars avatar Dec 05 '14 21:12 magnars

@magnars that's true :( suggest to switch to https://github.com/jakubpawlowicz/clean-css

tadatuta avatar Dec 05 '14 22:12 tadatuta

Very sad, csso idea is great

silentroach avatar Dec 05 '14 23:12 silentroach

@silentroach yeah, but nowadays structural optimisations are quite common idea

tadatuta avatar Dec 06 '14 00:12 tadatuta

new hope!

silentroach avatar Oct 16 '15 16:10 silentroach

It's similar to #143, but examples could be useful for tests.

lahmatiy avatar Oct 16 '15 23:10 lahmatiy

Current output for first example:

.support-question .closed,.support-question .opened {
    background: url('/s/a/i/ic/util.gif') no-repeat top right;
    white-space: nowrap;
    padding-right: 15px
}

.support-question .closed {
    background-position: right -65px
}

.support-question .opened {
    background-position: right -450px
}

It's correct. But because of good enough declaration positions. Second example is still fail...

lahmatiy avatar Jan 29 '16 21:01 lahmatiy

What about second example, it's even possible without context? How csso can know which block is encapsulates other?

ArturAralin avatar Jun 17 '16 19:06 ArturAralin

@ArturAralin what context your talking about? All we need is knowledge about shorthand properties and others (I call it property family) to make proper merge. If you're interesting in problem here is the branch where I started work on this problem (unfinished yet).

lahmatiy avatar Jun 17 '16 22:06 lahmatiy