From 93ab31a485730394018ac7358f3fb00b258037ad Mon Sep 17 00:00:00 2001 From: Mika Murtojarvi Date: Fri, 9 Jan 2015 17:50:26 +0200 Subject: [PATCH] Add spaces around operators (#16696). This is needed for the Sass compiler to correctly parse an expression. Change-Id: Ie39134e47f701015a9fc7180de5c033b80abe178 --- .../functions/_transition-property-name.scss | 2 +- WebContent/VAADIN/themes/valo/util/readme.txt | 8 +++ .../tests/CompileTransitionPropertyTest.java | 69 +++++++++++++++++++ server/tests/src/com/vaadin/tests/styles.scss | 5 ++ 4 files changed, 83 insertions(+), 1 deletion(-) create mode 100644 WebContent/VAADIN/themes/valo/util/readme.txt create mode 100644 server/tests/src/com/vaadin/tests/CompileTransitionPropertyTest.java create mode 100644 server/tests/src/com/vaadin/tests/styles.scss diff --git a/WebContent/VAADIN/themes/valo/util/bourbon/functions/_transition-property-name.scss b/WebContent/VAADIN/themes/valo/util/bourbon/functions/_transition-property-name.scss index 111deeb70f..6ceae72102 100644 --- a/WebContent/VAADIN/themes/valo/util/bourbon/functions/_transition-property-name.scss +++ b/WebContent/VAADIN/themes/valo/util/bourbon/functions/_transition-property-name.scss @@ -14,7 +14,7 @@ @function transition-property-name($prop, $vendor: false) { // put other properties that need to be prefixed here aswell @if $vendor and $prop == transform { - @return unquote('-'+$vendor+'-'+$prop); + @return unquote('-' + $vendor + '-' + $prop); } @else { @return $prop; diff --git a/WebContent/VAADIN/themes/valo/util/readme.txt b/WebContent/VAADIN/themes/valo/util/readme.txt new file mode 100644 index 0000000000..6da898220f --- /dev/null +++ b/WebContent/VAADIN/themes/valo/util/readme.txt @@ -0,0 +1,8 @@ +The Bourbon library has been modified to work around the limitations of the Sass Compiler. +The following changes should be taken into account if Bourbon is upgraded to a newer +version: + +file _transition-property-name.scss, function transition-property-name: added space around +the operation '+'. This changed one line from +@return unquote('-'+$vendor+'-'+$prop); +to @return unquote('-' + $vendor + '-' + $prop); \ No newline at end of file diff --git a/server/tests/src/com/vaadin/tests/CompileTransitionPropertyTest.java b/server/tests/src/com/vaadin/tests/CompileTransitionPropertyTest.java new file mode 100644 index 0000000000..d6c564a42b --- /dev/null +++ b/server/tests/src/com/vaadin/tests/CompileTransitionPropertyTest.java @@ -0,0 +1,69 @@ +/* + * Copyright 2000-2014 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests; + +import static org.junit.Assert.assertTrue; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.junit.Test; + +import com.vaadin.sass.internal.ScssStylesheet; + +/* + * This test checks that the transition mixin in valo/bourbon is usable (#15484). + */ +public class CompileTransitionPropertyTest { + + @Test + public void testCompilation() throws Exception { + ScssStylesheet ss = ScssStylesheet + .get("server/tests/src/com/vaadin/tests/styles.scss"); + ss.compile(); + // extract the style rules for .my-label + String compiled = ss.printState(); + Pattern pattern = Pattern.compile("(.my-label)(\\s)+(\\{)[^\\}]*"); + Matcher matcher = pattern.matcher(compiled); + assertTrue("Could not find style rules for .my-label.", matcher.find()); + String elementStyle = matcher.group(); + elementStyle = elementStyle.replaceFirst( + "(.my-label)(\\s)+(\\{)(\\s)*", ""); + // Check that the correct rules are present + Pattern p1 = Pattern + .compile("transition-property(\\s*):(\\s*)transform(\\s*);"); + Pattern p2 = Pattern + .compile("-moz-transition-property(\\s*):(\\s*)-moz-transform(\\s*);"); + Pattern p3 = Pattern + .compile("-webkit-transition-property(\\s*):(\\s*)-webkit-transform(\\s*);"); + assertTrue("The style 'transition-property: transform' is missing.", p1 + .matcher(elementStyle).find()); + assertTrue( + "The style '-moz-transition-property: -moz-transform' is missing.", + p2.matcher(elementStyle).find()); + assertTrue( + "The style '-webkit-transition-property: -webkit-transform' is missing.", + p3.matcher(elementStyle).find()); + // Check that there are no other styles for .my-label + String modifiedStyle = p1.matcher(elementStyle).replaceFirst(""); + modifiedStyle = p2.matcher(modifiedStyle).replaceFirst(""); + modifiedStyle = p3.matcher(modifiedStyle).replaceFirst(""); + // Only whitespace should remain after removing the style rules + modifiedStyle = modifiedStyle.replaceAll("(\\s)", ""); + assertTrue("Unexpected style rules for .my-label: " + modifiedStyle, + modifiedStyle.length() == 0); + } +} \ No newline at end of file diff --git a/server/tests/src/com/vaadin/tests/styles.scss b/server/tests/src/com/vaadin/tests/styles.scss new file mode 100644 index 0000000000..d574243969 --- /dev/null +++ b/server/tests/src/com/vaadin/tests/styles.scss @@ -0,0 +1,5 @@ +@import "../../../../../../WebContent/VAADIN/themes/valo/valo"; + +.my-label { + @include transition-property (transform); +} \ No newline at end of file -- 2.39.5