[gjs] Format: be future proof against fixes in SpiderMonkey



commit 2cf42c598c0e43394b3fe1cb7d50d3ed716ca3c4
Author: Giovanni Campagna <gcampagn cs stanford edu>
Date:   Thu Aug 18 13:17:06 2016 -0700

    Format: be future proof against fixes in SpiderMonkey
    
    Modern JS engines (in Firefox and Chrome, as well as node) pass
    undefined, not '', to the replaced function for groups that are not matched.
    Be future proof against changes that might go unnoticed when
    porting to SpiderMonkey 31/38/45/whatever that will be, and also
    if people extract this code and use it against different engines.
    
    (At least SM 34 has the right behavior, not sure about 31)
    
    https://bugzilla.gnome.org/show_bug.cgi?id=770111

 modules/format.js |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
---
diff --git a/modules/format.js b/modules/format.js
index 430b5d7..a3cb297 100644
--- a/modules/format.js
+++ b/modules/format.js
@@ -52,7 +52,7 @@ function vprintf(str, args) {
             s = parseInt(getArg()).toString(16);
             break;
         case 'f':
-            if (precisionGroup == '')
+            if (precisionGroup === '' || precisionGroup === undefined)
                 s = parseFloat(getArg()).toString();
             else
                 s = parseFloat(getArg()).toFixed(parseInt(precisionGroup));


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]