From a3c808e913b904fecab478c3b75aa22e583c9f62 Mon Sep 17 00:00:00 2001 From: Paul Gschwendtner Date: Thu, 1 Sep 2016 21:05:22 +0200 Subject: [PATCH] fix(theming): match preceding selectors as well * The theming service currently only matches from the beginning of the `md-default-theme`, but all preceding selectors are being ignored. Fixes #9480 --- gulp/util.js | 10 +++++++--- src/core/services/theming/theming.js | 7 ++++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/gulp/util.js b/gulp/util.js index 6e75cc65dc3..9e9d8f1cf82 100644 --- a/gulp/util.js +++ b/gulp/util.js @@ -84,13 +84,15 @@ function autoprefix () { ]}); } -function minifyCss() { - return nano({ +function minifyCss(extraOptions) { + var options = { autoprefixer: false, reduceTransforms: false, svgo: false, safe: true - }); + }; + + return nano(_.assign(options, extraOptions)); } function buildModule(module, opts) { @@ -229,6 +231,8 @@ function themeBuildStream() { .pipe(utils.hoistScssVariables()) .pipe(sass()) .pipe(dedupeCss()) + // The PostCSS orderedValues plugin modifies the theme color expressions. + .pipe(minifyCss({ orderedValues: false })) .pipe(utils.cssToNgConstant('material.core', '$MD_THEME_CSS')); } diff --git a/src/core/services/theming/theming.js b/src/core/services/theming/theming.js index 31ebe485901..2892c2bc7f1 100644 --- a/src/core/services/theming/theming.js +++ b/src/core/services/theming/theming.js @@ -744,9 +744,10 @@ function parseRules(theme, colorType, rules) { // Don't apply a selector rule to the default theme, making it easier to override // styles of the base-component if (theme.name == 'default') { - var themeRuleRegex = /((?:(?:(?: |>|\.|\w|-|:|\(|\)|\[|\]|"|'|=)+) )?)((?:(?:\w|\.|-)+)?)\.md-default-theme((?: |>|\.|\w|-|:|\(|\)|\[|\]|"|'|=)*)/g; - newRule = newRule.replace(themeRuleRegex, function(match, prefix, target, suffix) { - return match + ', ' + prefix + target + suffix; + var themeRuleRegex = /((?:\s|>|\.|\w|-|:|\(|\)|\[|\]|"|'|=)*)\.md-default-theme((?:\s|>|\.|\w|-|:|\(|\)|\[|\]|"|'|=)*)/g; + + newRule = newRule.replace(themeRuleRegex, function(match, start, end) { + return match + ', ' + start + end; }); } generatedRules.push(newRule);