You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by gc...@apache.org on 2012/02/21 22:17:58 UTC

svn commit: r1292038 - /myfaces/trinidad/trunk/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/CoreFormat.js

Author: gcrawford
Date: Tue Feb 21 21:17:57 2012
New Revision: 1292038

URL: http://svn.apache.org/viewvc?rev=1292038&view=rev
Log:
TRINIDAD-2219 Negative numbers for Bidi/RTL languages are not handled correctly

Thanks to Bino

Modified:
    myfaces/trinidad/trunk/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/CoreFormat.js

Modified: myfaces/trinidad/trunk/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/CoreFormat.js
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/CoreFormat.js?rev=1292038&r1=1292037&r2=1292038&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/CoreFormat.js (original)
+++ myfaces/trinidad/trunk/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/CoreFormat.js Tue Feb 21 21:17:57 2012
@@ -1013,8 +1013,18 @@ function _decimalParse(
     // decimal separator allowed by JS
     var decimal = new RegExp("\\" + symbols.getDecimalSeparator(),  "g");
     numberString = numberString.replace(decimal, ".");
-  }
 
+    // JIRA TRINIDAD-2219: When the string is a negative bidi number, e.g. "1-", the
+    //(numberString*numberString) and (numberString / numberString) return NaN
+    // and is unable to parse it so additional handling is needed for such cases.
+    var negativeSuffix = symbols.getNegativeSuffix();
+    var numberStringLength = numberString.length ;
+  
+    if(negativeSuffix != null && numberString.lastIndexOf(negativeSuffix) ==  (numberStringLength - 1)) 
+    {
+      numberString = "-" + numberString.substring(0, numberStringLength - 1);
+    }
+  }
 
   // OK; it's non-empty.  Now, disallow exponential
   // notation, and then use some JS magic to exclude