From 9721433399a661d6aeef8a8af3df00045636fdca Mon Sep 17 00:00:00 2001 From: Daniel Freedman Date: Wed, 24 Jan 2018 14:16:10 -0800 Subject: [PATCH] Port keyframe name fix from ShadyCSS (#5038) * Port keyframe name fix from ShadyCSS Fixes #3475 * animate border instead * Port Edge 16 test fixes from 2.x --- src/lib/style-properties.html | 5 +- test/unit/custom-style.html | 5 ++ test/unit/styling-cross-scope-apply.html | 5 ++ test/unit/styling-cross-scope-var.html | 70 ++++++++++++++++++++++++ test/unit/styling-scoped.html | 5 ++ 5 files changed, 89 insertions(+), 1 deletion(-) diff --git a/src/lib/style-properties.html b/src/lib/style-properties.html index 8db904f641..da40707b43 100644 --- a/src/lib/style-properties.html +++ b/src/lib/style-properties.html @@ -419,7 +419,10 @@ // Transforms `@keyframes` names to be unique for the current host. // Example: @keyframes foo-anim -> @keyframes foo-anim-x-foo-0 _scopeKeyframes: function(rule, scopeId) { - rule.keyframesNameRx = new RegExp(rule.keyframesName, 'g'); + // Animation names are of the form [\w-], so ensure that the name regex does not partially apply + // to similarly named keyframe names by checking for a word boundary at the beginning and + // a non-word boundary or `-` at the end. + rule.keyframesNameRx = new RegExp('\\b' + rule.keyframesName + '(?!\\B|-)', 'g'); rule.transformedKeyframesName = rule.keyframesName + '-' + scopeId; rule.transformedSelector = rule.transformedSelector || rule.selector; rule.selector = rule.transformedSelector.replace( diff --git a/test/unit/custom-style.html b/test/unit/custom-style.html index 7b34a2f39a..7b3024da5f 100644 --- a/test/unit/custom-style.html +++ b/test/unit/custom-style.html @@ -595,6 +595,11 @@ assertComputed(el, '11px', 'right'); assertComputed(el, '12px', 'top'); + // Avoid Edge 16 bug with CSS Custom Properties and Fonts. + if (navigator.userAgent.match('Edge/16') && Polymer.Settings.useNativeCSSProperties) { + return; + } + // Because FireFox and Chrome parse font-family differently... var computed = getComputedStyle(el); assert.equal(computed['font-family'].replace(/['"]+/g, ''), 'Varela font'); diff --git a/test/unit/styling-cross-scope-apply.html b/test/unit/styling-cross-scope-apply.html index 58070d8b86..09733a44f1 100644 --- a/test/unit/styling-cross-scope-apply.html +++ b/test/unit/styling-cross-scope-apply.html @@ -813,6 +813,11 @@ }) test('mixins apply to @keyframe rules', function(done) { + if (navigator.userAgent.match('Edge/16') && Polymer.Settings.useNativeCSSProperties) { + // skip test due to missing variable support in keyframes + // https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/12084341/ + this.skip(); + } var xKeyframes1 = styled.$.keyframes1; var xKeyframes2 = styled.$.keyframes2; var completed = 0; diff --git a/test/unit/styling-cross-scope-var.html b/test/unit/styling-cross-scope-var.html index 324ab3530a..0eacbb6fe9 100644 --- a/test/unit/styling-cross-scope-var.html +++ b/test/unit/styling-cross-scope-var.html @@ -375,6 +375,57 @@ + + + + +