]> source.dussan.org Git - vaadin-framework.git/commitdiff
Referencing multiple params in multiple lines inside mixin (Ticket
authorHaijian Wang <haijian@vaadin.com>
Tue, 12 Feb 2013 09:54:10 +0000 (11:54 +0200)
committerHaijian Wang <haijian@vaadin.com>
Tue, 12 Feb 2013 09:54:10 +0000 (11:54 +0200)
#10987)

Change-Id: I3d97849afac763a9774cee254778e068f94a23e0

theme-compiler/src/com/vaadin/sass/internal/parser/LexicalUnitImpl.java
theme-compiler/tests/resources/automatic/css/mixin-multiple-params.css [new file with mode: 0644]
theme-compiler/tests/resources/automatic/scss/mixin-multiple-params.scss [new file with mode: 0644]

index 3527a77642e5946c09db877c17de20a6a3dfd667..ae097537b93f21ef46c960874b41a6cbbf4492e2 100644 (file)
@@ -28,6 +28,7 @@ import java.io.Serializable;
 import org.w3c.css.sac.LexicalUnit;
 
 import com.vaadin.sass.internal.util.ColorUtil;
+import com.vaadin.sass.internal.util.DeepCopy;
 
 /**
  * @version $Revision: 1.3 $
@@ -380,23 +381,26 @@ public class LexicalUnitImpl implements LexicalUnit, SCSSLexicalUnit,
     }
 
     public void replaceValue(LexicalUnitImpl another) {
-        type = another.getLexicalUnitType();
-        i = another.getIntegerValue();
-        f = another.getFloatValue();
-        s = another.getStringValue();
-        fname = another.getFunctionName();
-        prev = another.getPreviousLexicalUnit();
-        dimension = another.getDimension();
-        sdimension = another.getSdimension();
-        params = another.getParameters();
-
-        LexicalUnitImpl finalNextInAnother = another;
+        // shouldn't modify 'another' directly, should only modify its copy.
+        LexicalUnitImpl deepCopyAnother = (LexicalUnitImpl) DeepCopy
+                .copy(another);
+        type = deepCopyAnother.getLexicalUnitType();
+        i = deepCopyAnother.getIntegerValue();
+        f = deepCopyAnother.getFloatValue();
+        s = deepCopyAnother.getStringValue();
+        fname = deepCopyAnother.getFunctionName();
+        prev = deepCopyAnother.getPreviousLexicalUnit();
+        dimension = deepCopyAnother.getDimension();
+        sdimension = deepCopyAnother.getSdimension();
+        params = deepCopyAnother.getParameters();
+
+        LexicalUnitImpl finalNextInAnother = deepCopyAnother;
         while (finalNextInAnother.getNextLexicalUnit() != null) {
             finalNextInAnother = finalNextInAnother.getNextLexicalUnit();
         }
 
         finalNextInAnother.setNextLexicalUnit(next);
-        next = another.next;
+        next = deepCopyAnother.next;
     }
 
     public void setParameters(LexicalUnitImpl params) {
@@ -617,8 +621,7 @@ public class LexicalUnitImpl implements LexicalUnit, SCSSLexicalUnit,
 
     @Override
     public LexicalUnitImpl clone() {
-        LexicalUnitImpl cloned = new LexicalUnitImpl(type, line, column,
-                (LexicalUnitImpl) prev);
+        LexicalUnitImpl cloned = new LexicalUnitImpl(type, line, column, prev);
         cloned.replaceValue(this);
         return cloned;
     }
@@ -636,8 +639,9 @@ public class LexicalUnitImpl implements LexicalUnit, SCSSLexicalUnit,
             return i;
         } else if (f != -1) {
             return f;
-        } else
+        } else {
             return null;
+        }
     }
 
     public void setFunctionName(String functionName) {
diff --git a/theme-compiler/tests/resources/automatic/css/mixin-multiple-params.css b/theme-compiler/tests/resources/automatic/css/mixin-multiple-params.css
new file mode 100644 (file)
index 0000000..affb478
--- /dev/null
@@ -0,0 +1,4 @@
+-webkit-test: foo bar;
+-moz-test: foo bar;
+-webkit-test: foo bar zoo;
+-moz-test: foo bar zoo;
\ No newline at end of file
diff --git a/theme-compiler/tests/resources/automatic/scss/mixin-multiple-params.scss b/theme-compiler/tests/resources/automatic/scss/mixin-multiple-params.scss
new file mode 100644 (file)
index 0000000..2695ef9
--- /dev/null
@@ -0,0 +1,10 @@
+@mixin test2 ($p1, $p2) {
+       -webkit-test: $p1 $p2;
+       -moz-test: $p1 $p2;
+}
+@mixin test3 ($p1, $p2, $p3) {
+       -webkit-test: $p1 $p2 $p3;
+       -moz-test: $p1 $p2 $p3;
+}
+@include test2(foo, bar);
+@include test3(foo, bar, zoo);
\ No newline at end of file