diff --git a/packages/mdc-checkbox/_mixins.scss b/packages/mdc-checkbox/_mixins.scss index b7d8c56ace4..be0105f6616 100644 --- a/packages/mdc-checkbox/_mixins.scss +++ b/packages/mdc-checkbox/_mixins.scss @@ -26,6 +26,7 @@ @import "@material/feature-targeting/mixins"; @import "@material/ripple/mixins"; @import "@material/touch-target/mixins"; +@import "@material/theme/functions"; @import "./functions"; @import "./keyframes"; @import "./variables"; @@ -297,7 +298,11 @@ $mdc-checkbox-ripple-target: ".mdc-checkbox__ripple"; } @if $generate-keyframes { - $uid: unique-id(); + $uid: mdc-theme-color-hash($unmarked-stroke-color) + + mdc-theme-color-hash($marked-stroke-color) + + mdc-theme-color-hash($unmarked-fill-color) + + mdc-theme-color-hash($marked-fill-color); + $anim-selector: if(&, "&.mdc-checkbox--anim", ".mdc-checkbox--anim"); @include mdc-feature-targets($feat-animation, $feat-color) { @@ -306,7 +311,7 @@ $mdc-checkbox-ripple-target: ".mdc-checkbox__ripple"; $to-stroke-color: $marked-stroke-color, $from-fill-color: $unmarked-fill-color, $to-fill-color: $marked-fill-color, - $uid: $uid + $uid: #{$uid} ); } diff --git a/packages/mdc-theme/_functions.scss b/packages/mdc-theme/_functions.scss index 93c67eaf333..826205351d1 100644 --- a/packages/mdc-theme/_functions.scss +++ b/packages/mdc-theme/_functions.scss @@ -79,3 +79,16 @@ @return var(#{$var}, $fallback); } + +/// +/// @param $color Target color in any color format. +/// @return Returns hash in string format that uniquely represents +/// any given color format. Useful for generating unique keyframe names. +/// +@function mdc-theme-color-hash($color) { + @if type-of($color) == "string" { + @return $color; + } + + @return str-slice(ie-hex-str($color), 2); +} diff --git a/testing/dom/events.ts b/testing/dom/events.ts index 731752a24d8..a894fd71272 100644 --- a/testing/dom/events.ts +++ b/testing/dom/events.ts @@ -27,17 +27,17 @@ * supported. */ export function emitEvent( - targetEl: Element, eventName: string, {bubbles, cancelable}: EventInit = { - bubbles: false, - cancelable: false - }) { -let event; -if (typeof(Event) === 'function') { - event = new Event(eventName, {bubbles, cancelable}); -} else { - // IE11 support. - event = document.createEvent('Event'); - event.initEvent(eventName, bubbles, cancelable); -} -targetEl.dispatchEvent(event); + targetEl: Element, eventName: string, {bubbles, cancelable}: EventInit = { + bubbles: false, + cancelable: false + }) { + let event; + if (typeof(Event) === 'function') { + event = new Event(eventName, {bubbles, cancelable}); + } else { + // IE11 support. + event = document.createEvent('Event'); + event.initEvent(eventName, bubbles, cancelable); + } + targetEl.dispatchEvent(event); }