From 99d0a606de4daf94d23cb8a46e79ee0292152f29 Mon Sep 17 00:00:00 2001 From: Daniel Freedman Date: Thu, 11 Jan 2018 10:05:53 -0800 Subject: [PATCH 1/3] Port keyframe name fix from ShadyCSS Fixes #3475 --- src/lib/style-properties.html | 5 +- test/unit/styling-cross-scope-var.html | 70 ++++++++++++++++++++++++++ 2 files changed, 74 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/styling-cross-scope-var.html b/test/unit/styling-cross-scope-var.html index 324ab3530a..8fc19b34cc 100644 --- a/test/unit/styling-cross-scope-var.html +++ b/test/unit/styling-cross-scope-var.html @@ -375,6 +375,56 @@ + + + + +