Monday, January 13, 2014

Re: Differences between DevMode and Production mode related to trim()

Thank you Jens.

It does look like there is a real difference between Java's trim() and the following JavaScript:

  1. var r1 = this.replace(/^(\s*)/, '');
  2. var r2 = r1.replace(/\s*$/, '');

A JavaScript whitespace character can be:

  • A space character
  • A tab character
  • A carriage return character
  • A new line character
  • A vertical tab character
  • A form feed character
Our Strings are all filled with null characters ('\0')) due to our ancient C backend. trim() in Java works perfectly for this. But GWT's production/JavaScript trim() does not work. This leads to much of our app being broken due to comparison checks that worked in DevMode, not working in production.

We are going to have to remove every instance of trim() (just under 100) from our client side code base. This of course has the possibility of introducing other bugs and display issues. We can replace the usages of trim().isEmpty() with checks for charAt(0) == '\0' but it is not as clean.

Another option is to just fix this issue in the SDK and ship our production product with a modified GWT SDK, but I think that there would be some management/customers unhappy with this.


On Friday, December 27, 2013 5:56:44 PM UTC-5, Jens wrote:
GWT does not use the JS trim() method because of browser compatibility.


Maybe this implementation is not compatible with the contents of your String. In Java everything below \u0020 will be removed. Maybe thats not the case when using JavaScript "\s" RegExp.

-- J.

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/groups/opt_out.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate