Skip to content

Commit

Permalink
don't merge text-align with some new values (fixes #281)
Browse files Browse the repository at this point in the history
  • Loading branch information
lahmatiy committed Mar 10, 2016
1 parent 67674ef commit a2a8642
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
11 changes: 8 additions & 3 deletions lib/compressor/restructure/6-restructBlock.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@ var dontRestructure = {
'src': 1 // https://github.com/afelix/csso/issues/50
};

// https://developer.mozilla.org/en-US/docs/Web/CSS/display#Browser_compatibility
var DISPLAY_DONT_MIX_VALUE = /table|ruby|flex|-(flex)?box$|grid|contents|run-in/;
var DONT_MIX_VALUE = {
// https://developer.mozilla.org/en-US/docs/Web/CSS/display#Browser_compatibility
'display': /table|ruby|flex|-(flex)?box$|grid|contents|run-in/i,
// https://developer.mozilla.org/en/docs/Web/CSS/text-align
'text-align': /^(start|end|match-parent|justify-all)$/i
};

var NEEDLESS_TABLE = {
'border-width': ['border'],
Expand Down Expand Up @@ -77,7 +81,8 @@ function getPropertyFingerprint(propertyName, declaration, fingerprints) {
hack9 = name;
}

if (realName === 'display' && DISPLAY_DONT_MIX_VALUE.test(name)) {
if (DONT_MIX_VALUE.hasOwnProperty(realName) &&
DONT_MIX_VALUE[realName].test(name)) {
special[name] = true;
}

Expand Down
15 changes: 15 additions & 0 deletions test/fixture/compress/property-merge/text-align.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
issue 281 start/end/match-parent/justify-all values has different browser support
*/

.test {
text-align: left;
text-align: right;
text-align: center;
text-align: justify;
text-align: start;
text-align: end;
text-align: match-parent;
text-align: justify-all;
text-align: start;
}
1 change: 1 addition & 0 deletions test/fixture/compress/property-merge/text-align.min.css
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.test{text-align:justify;text-align:end;text-align:match-parent;text-align:justify-all;text-align:start}

0 comments on commit a2a8642

Please sign in to comment.