Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.

Commit efb7031

Browse files
devversionkara
authored andcommitted
fix(theming): match preceding selectors as well (#9484)
* The theming service currently only matches from the beginning of the `md-default-theme`, but all preceding selectors are being ignored. Fixes #9480
1 parent 0032184 commit efb7031

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

gulp/util.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,15 @@ function autoprefix () {
8484
]});
8585
}
8686

87-
function minifyCss() {
88-
return nano({
87+
function minifyCss(extraOptions) {
88+
var options = {
8989
autoprefixer: false,
9090
reduceTransforms: false,
9191
svgo: false,
9292
safe: true
93-
});
93+
};
94+
95+
return nano(_.assign(options, extraOptions));
9496
}
9597

9698
function buildModule(module, opts) {
@@ -229,6 +231,8 @@ function themeBuildStream() {
229231
.pipe(utils.hoistScssVariables())
230232
.pipe(sass())
231233
.pipe(dedupeCss())
234+
// The PostCSS orderedValues plugin modifies the theme color expressions.
235+
.pipe(minifyCss({ orderedValues: false }))
232236
.pipe(utils.cssToNgConstant('material.core', '$MD_THEME_CSS'));
233237
}
234238

src/core/services/theming/theming.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -744,9 +744,10 @@ function parseRules(theme, colorType, rules) {
744744
// Don't apply a selector rule to the default theme, making it easier to override
745745
// styles of the base-component
746746
if (theme.name == 'default') {
747-
var themeRuleRegex = /((?:(?:(?: |>|\.|\w|-|:|\(|\)|\[|\]|"|'|=)+) )?)((?:(?:\w|\.|-)+)?)\.md-default-theme((?: |>|\.|\w|-|:|\(|\)|\[|\]|"|'|=)*)/g;
748-
newRule = newRule.replace(themeRuleRegex, function(match, prefix, target, suffix) {
749-
return match + ', ' + prefix + target + suffix;
747+
var themeRuleRegex = /((?:\s|>|\.|\w|-|:|\(|\)|\[|\]|"|'|=)*)\.md-default-theme((?:\s|>|\.|\w|-|:|\(|\)|\[|\]|"|'|=)*)/g;
748+
749+
newRule = newRule.replace(themeRuleRegex, function(match, start, end) {
750+
return match + ', ' + start + end;
750751
});
751752
}
752753
generatedRules.push(newRule);

0 commit comments

Comments
 (0)