aboutsummaryrefslogtreecommitdiffstats
path: root/gwtquery-core
diff options
context:
space:
mode:
authorManuel Carrasco Moñino <manuel.carrasco.m@gmail.com>2013-02-22 11:50:47 +0100
committerManuel Carrasco Moñino <manuel.carrasco.m@gmail.com>2013-02-22 11:50:47 +0100
commitc36e403dc90a0d0e4fb4ce40ad225acc3db7da7d (patch)
treed07be049872dc071b7e877648e2a8c656b8c8c44 /gwtquery-core
parent4b54760eeee2a678f76e0e5d05b44a9ae9c235c2 (diff)
downloadgwtquery-c36e403dc90a0d0e4fb4ce40ad225acc3db7da7d.tar.gz
gwtquery-c36e403dc90a0d0e4fb4ce40ad225acc3db7da7d.zip
Fix edge case when properties string ends with coma
Diffstat (limited to 'gwtquery-core')
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/Properties.java3
-rw-r--r--gwtquery-core/src/test/java/com/google/gwt/query/client/JreQueryCoreTest.java2
2 files changed, 3 insertions, 2 deletions
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 cc8d6b3f..8e68b184 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
@@ -48,7 +48,7 @@ public class Properties extends JavaScriptObject {
.replaceAll("\\s+([:\\)\\(,;}{'\"])" , "$1") // Remove spaces
.replaceFirst("^[\\(]+(.*)[\\)]+$", "$1") // Remove ()
.replaceAll("\\([\"']([^\\)]+)[\"']\\)" , "($1)") // Remove quotes
- .replaceAll("[;,]+([\\w-\\$]+):", ";$1:") // Change comma by semicolon
+ .replaceAll("[;,]+([\\w-\\$]+:|$)", ";$1") // Change comma by semicolon
.replaceAll("([^,;])([\\]}])", "$1;$2") // Put control semicolon used below
.replaceAll(":\\s*[\"']?([^;\\{\\}\\[\\]\"']*)[\"']?\\s*([;,]+|$)", ":\"$1\";") // put quotes to all values (even empty)
.replaceAll("[;,]+([\\w-]+):", ";$1:") // Change semicolon by comma
@@ -61,6 +61,7 @@ public class Properties extends JavaScriptObject {
.replaceAll("[;,]+([\\]\\}]|$)", "$1") // remove endings
;
ret = ret.matches("(^[\\[\\{].*[\\]\\}]$)") ? ret : "{" + ret + "}";
+ System.out.println(s + " -> " + ret);
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 af755243..e92654f7 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
@@ -47,7 +47,7 @@ public class JreQueryCoreTest extends GWTTestCase {
assertEquals("{\"width\":\"\",\"top\":\"\"}", Properties
.wrapPropertiesString("width: '' ; top:'' ;"));
assertEquals("{\"border-left\":\"solid\"}", Properties
- .wrapPropertiesString("border-left: solid"));
+ .wrapPropertiesString("border-left: solid,"));
assertEquals("[{\"a\":1,\"b\":{\"a\":2,\"b\":{\"a\":3}},\"u\":\"url\",\"d\":2,\"t\":[\"hola\",\"adios\"],\"z\":true}]", Properties
.wrapPropertiesString("[{a:1, b:{a:2,b:{a:3}},u:url, d:'2','t':['hola','adios'], 'z': true}]"));
assertEquals("{\"$x\":22.60,\"$y\":\".0\",\"h\":\"#y\"}", Properties