You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Sep 5, 2024. It is now read-only.
When a theme is provided via the mdTheme directive on a parent of an element which utilises the mdColors directive, and mdColors is using a dynamic expression, the colour fails to update.
What is the expected behavior?
mdColors can be used with a dynamic expression regardless of whether a theme has been explicitly specified.
The pen shows two panels, which are identical in functionality, save for the fact that the panel on the right explicitly specifies 'md-theme="default"'. As can be seen, the panel on the left changes colour to the selected palette. The panel on the right does not.
00:39:47.004 Error: mdColors: couldn't find '[object object]' in the palettes.Stack trace:extractPalette@https://ajax.googleapis.com/ajax/libs/angular_material/1.1.0-rc.5/angular-material.js:7449:17extractColorOptions@https://ajax.googleapis.com/ajax/libs/angular_material/1.1.0-rc.5/angular-material.js:7427:18interpolateColors/<@https://ajax.googleapis.com/ajax/libs/angular_material/1.1.0-rc.5/angular-material.js:7395:21q@https://ajax.googleapis.com/ajax/libs/angularjs/1.5.6/angular.min.js:8:1interpolateColors@https://ajax.googleapis.com/ajax/libs/angular_material/1.1.0-rc.5/angular-material.js:7394:7applyThemeColors@https://ajax.googleapis.com/ajax/libs/angular_material/1.1.0-rc.5/angular-material.js:7332:21bb/<@https://ajax.googleapis.com/ajax/libs/angularjs/1.5.6/angular.min.js:16:150uf/this.$get</m.prototype.$digest@https://ajax.googleapis.com/ajax/libs/angularjs/1.5.6/angular.min.js:142:443uf/this.$get</m.prototype.$apply@https://ajax.googleapis.com/ajax/libs/angularjs/1.5.6/angular.min.js:145:399listener@https://ajax.googleapis.com/ajax/libs/angular_material/1.1.0-rc.5/angular-material.js:18056:7Rf@https://ajax.googleapis.com/ajax/libs/angularjs/1.5.6/angular.min.js:37:31Qf/d@https://ajax.googleapis.com/ajax/libs/angularjs/1.5.6/angular.min.js:36:486
So, I've had a look into the issue, and I've found what I think is the source of the problem - the culprit is line 7558 of angular-material.js (1.1.0-rc.5), colors[prop] = (theme || mdThemeController.$mdTheme) + '-' + color;.
It looks like what's happening is that when the expression for mdColors is dynamic, parseColors is added as a watchExpression (7583), which would be fine, but watchExpressions are called with scope as a parameter, whereas parseColors is expecting an optional 'theme' as a parameter. When md-theme is present, mdThemeController is not null on line 7554 meaning line 7558 gets executed, which prepends the name of the theme to the color expression. The 'theme' parameter takes precedence over mdThemeController.$mdTheme, but because 'theme' is actually a scope object, we end up with an expression like '[object object]-accent' instead of 'default-accent', leading to the error seen in the stack trace.
The text was updated successfully, but these errors were encountered:
- scope.$watch was calling parseColors with a scope and not a theme string, which caused the theme parsing when mdThemeController is present to be incorrect
fixes#8720
Uh oh!
There was an error while loading. Please reload this page.
Actual behavior:
When a theme is provided via the mdTheme directive on a parent of an element which utilises the mdColors directive, and mdColors is using a dynamic expression, the colour fails to update.
mdColors can be used with a dynamic expression regardless of whether a theme has been explicitly specified.
CodePen or Steps to reproduce the issue: *
The pen shows two panels, which are identical in functionality, save for the fact that the panel on the right explicitly specifies 'md-theme="default"'. As can be seen, the panel on the left changes colour to the selected palette. The panel on the right does not.
Angular Versions: *
Additional Information:
So, I've had a look into the issue, and I've found what I think is the source of the problem - the culprit is line 7558 of angular-material.js (1.1.0-rc.5),
colors[prop] = (theme || mdThemeController.$mdTheme) + '-' + color;
.It looks like what's happening is that when the expression for mdColors is dynamic, parseColors is added as a watchExpression (7583), which would be fine, but watchExpressions are called with
scope
as a parameter, whereas parseColors is expecting an optional 'theme' as a parameter. When md-theme is present, mdThemeController is not null on line 7554 meaning line 7558 gets executed, which prepends the name of the theme to the color expression. The 'theme' parameter takes precedence overmdThemeController.$mdTheme
, but because 'theme' is actually ascope
object, we end up with an expression like '[object object]-accent' instead of 'default-accent', leading to the error seen in the stack trace.The text was updated successfully, but these errors were encountered: