tubalmartin / YUI-CSS-compressor-PHP-port

A PHP port of the YUI CSS compressor.
231 stars 34 forks source link

flexbox percentage removed #26

Closed futtta closed 7 years ago

futtta commented 8 years ago

{flex: 1 1 0%} is optimized into {flex:1 1 0}, which is not rendered the same in Chrome.

Cfr. Autoptimize support topic on https://wordpress.org/support/topic/google-chrome-css-flex-1-1-0-is-not-the-same-as-flex1-1-0

frank

damienmckenna commented 8 years ago

This also converts {flex: 1 0 0px} to {flex: 1 0 0}, which breaks IE11.

damienmckenna commented 8 years ago

The problem appears to be fixed in the latest chrome, it doesn't mind about the missing units anymore.

damienmckenna commented 8 years ago

The commit from @futtta may fix the percentage issue, but it doesn't fix the general units issue.

futtta commented 8 years ago

do you have example CSS for that @damienmckenna? I'll be happy to improve :-)

damienmckenna commented 8 years ago

How about something as simple as the following:

.child { flex: 1 0 0px; }

damienmckenna commented 8 years ago

@futtta, the latest code in your fork appears to resolve this, would you mind putting together a PR of just this fix so we could review it and make it easier to be included? All that's needed are these two bits:

        // Preserve flex, keeping units even if 0.
        $css = preg_replace_callback('/flex\s?:\s?((?:[0-9 ]*)\s?(?:px|em|auto|%)?(?:calc\(.*\))?)/i', array($this, 'replace_flex'), $css);
    private function replace_flex($matches)
    {
        $this->preserved_tokens[] = trim($matches[1]);
        return 'flex:'.self::TOKEN . (count($this->preserved_tokens) - 1) . '___';
    }

Thanks.

futtta commented 8 years ago

@damienmckenna; PR https://github.com/tubalmartin/YUI-CSS-compressor-PHP-port/issues/30 created

damienmckenna commented 8 years ago

@futtta: Excellent, that PR covers it!

tubalmartin commented 7 years ago

Fixed in v2.4.8-p7 release. Thank you guys!