From: Manolo Carrasco Date: Wed, 6 Apr 2011 08:42:19 +0000 (+0000) Subject: Properties constructor now accepts css syntax X-Git-Tag: release-1.3.2~432 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=a4f38b526593af33fed27a92041413a7893eede9;p=gwtquery.git Properties constructor now accepts css syntax --- diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/Properties.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/Properties.java index c95d4005..ce70e5a2 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/Properties.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/Properties.java @@ -46,7 +46,10 @@ public class Properties extends JavaScriptObject { public static String wrapPropertiesString(String s) { String ret = "({" + s.replaceFirst("^[({]+", "").replaceFirst("[})]+$", "") - .replaceAll(":\\s*([^\"'\\s])([^,}]+)\\s*", ":\"$1$2\"") + "})"; + .replaceAll("\\s*/\\*[\\s\\S]*?\\*/\\s*", "") + .replaceAll(":\\s*[\"']?([^;,]+)([,;]|$)[\"']?\\s*", ":'$1',") + .replaceFirst("[;,]$", "").replaceAll("\\s*[']+\\s*", "'") + + "})"; return ret; } diff --git a/gwtquery-core/src/test/java/com/google/gwt/query/client/JreQueryCoreTest.java b/gwtquery-core/src/test/java/com/google/gwt/query/client/JreQueryCoreTest.java index c84eb38f..bafac246 100644 --- a/gwtquery-core/src/test/java/com/google/gwt/query/client/JreQueryCoreTest.java +++ b/gwtquery-core/src/test/java/com/google/gwt/query/client/JreQueryCoreTest.java @@ -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');")); } }