Skip to content

Commit 0b0d779

Browse files
devversionmmalerba
authored andcommitted
refactor: remove ts 3.7 compatibility type cast in ripple-rend… (#17934)
8fd9d7d added a compatibility type cast to the ripple renderer. To actually fix the assignment in a non-cast way that works for TS 3.6 and TS 3.7, we just assign the `backgroundColor` style property if actually needed.
1 parent 8a42b98 commit 0b0d779

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/material/core/ripple/ripple-renderer.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,12 @@ export class RippleRenderer {
146146
ripple.style.height = `${radius * 2}px`;
147147
ripple.style.width = `${radius * 2}px`;
148148

149-
// If the color is not set, the default CSS color will be used.
150-
// TODO(TS3.7): Type 'string | null' is not assignable to type 'string'.
151-
ripple.style.backgroundColor = (config.color || null) as any;
149+
// If a custom color has been specified, set it as inline style. If no color is
150+
// set, the default color will be applied through the ripple theme styles.
151+
if (config.color != null) {
152+
ripple.style.backgroundColor = config.color;
153+
}
154+
152155
ripple.style.transitionDuration = `${duration}ms`;
153156

154157
this._containerElement.appendChild(ripple);

0 commit comments

Comments
 (0)