]> source.dussan.org Git - gwtquery.git/commitdiff
Properties constructor now accepts css syntax
authorManolo Carrasco <manolo@apache.org>
Wed, 6 Apr 2011 08:42:19 +0000 (08:42 +0000)
committerManolo Carrasco <manolo@apache.org>
Wed, 6 Apr 2011 08:42:19 +0000 (08:42 +0000)
gwtquery-core/src/main/java/com/google/gwt/query/client/Properties.java
gwtquery-core/src/test/java/com/google/gwt/query/client/JreQueryCoreTest.java

index c95d40052f05a70f567bf2f061981e3d7243b305..ce70e5a2c4fb73d5f59535e665660d0bfed81683 100644 (file)
@@ -46,7 +46,10 @@ public class Properties extends JavaScriptObject {
   public static String wrapPropertiesString(String s) {\r
     String ret = "({"\r
         + s.replaceFirst("^[({]+", "").replaceFirst("[})]+$", "")\r
-        .replaceAll(":\\s*([^\"'\\s])([^,}]+)\\s*", ":\"$1$2\"") + "})";\r
+        .replaceAll("\\s*/\\*[\\s\\S]*?\\*/\\s*", "")\r
+        .replaceAll(":\\s*[\"']?([^;,]+)([,;]|$)[\"']?\\s*", ":'$1',")\r
+        .replaceFirst("[;,]$", "").replaceAll("\\s*[']+\\s*", "'")\r
+        + "})";\r
     return ret;\r
   }\r
 \r
index c84eb38ff29d56f5b4c7f0d8c5c6e43e86144e37..bafac246e9dc4b33b3c0d72c9b351d1321e94874 100644 (file)
@@ -48,6 +48,8 @@ public class JreQueryCoreTest extends GWTTestCase {
         .wrapPropertiesString("{(border:'1px solid black')}"));
     assertEquals("({border:'1px solid black'})", Properties
         .wrapPropertiesString("({border:'1px solid black'})"));
+    assertEquals("({b:'a',c:'1',d:'url('adfafa')'})", Properties
+        .wrapPropertiesString("b: 'a'; c: 1, /*gg: aadf*/d: url('adfafa');"));
   }
 
 }