[gjs/wip/ptomato/mozjs52: 12/45] js: Module exports use ES6 scope rules



commit 6009410482ae85ee6a5e3218b62307158cf37a76
Author: Philip Chimento <philip chimento gmail com>
Date:   Sun Apr 16 23:21:49 2017 -0700

    js: Module exports use ES6 scope rules
    
    We "import" modules by executing them and taking their global scope as the
    module object. In ES6, variables declared with "let" and "const" do not end
    up in the global scope any longer. Instead, they end up in the "global
    lexical scope", which is a different object. Unfortunately, this means
    breaking the way many modules export their variables, but if you want
    a symbol to be exported, you have to declare it with "var" or place it
    explicitly on the global object some other way.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=781429

 installed-tests/js/modules/modunicode.js |    2 +-
 modules/cairo.js                         |   26 +++++++++++++-------------
 modules/gettext.js                       |    2 +-
 modules/signals.js                       |    2 +-
 4 files changed, 16 insertions(+), 16 deletions(-)
---
diff --git a/installed-tests/js/modules/modunicode.js b/installed-tests/js/modules/modunicode.js
index cbda9b8..560f5c8 100644
--- a/installed-tests/js/modules/modunicode.js
+++ b/installed-tests/js/modules/modunicode.js
@@ -1,3 +1,3 @@
 // This file is written in UTF-8.
 
-const uval = "const ♥ utf8";
+var uval = "const ♥ utf8";
diff --git a/modules/cairo.js b/modules/cairo.js
index 7555c3c..bc5ad57 100644
--- a/modules/cairo.js
+++ b/modules/cairo.js
@@ -20,32 +20,32 @@
 
 const Lang = imports.lang;
 
-const Antialias = {
+var Antialias = {
     DEFAULT: 0,
     NONE: 1,
     GRAY: 2,
     SUBPIXEL: 3
 };
 
-const Content = {
+var Content = {
     COLOR : 0x1000,
     ALPHA : 0x2000,
     COLOR_ALPHA : 0x3000
 };
 
-const Extend = {
+var Extend = {
     NONE : 0,
     REPEAT : 1,
     REFLECT : 2,
     PAD : 3
 };
 
-const FillRule = {
+var FillRule = {
     WINDING: 0,
     EVEN_ODD: 1
 };
 
-const Filter = {
+var Filter = {
     FAST : 0,
     GOOD : 1,
     BEST : 2,
@@ -54,18 +54,18 @@ const Filter = {
     GAUSSIAN : 5
 };
 
-const FontSlant = {
+var FontSlant = {
     NORMAL: 0,
     ITALIC: 1,
     OBLIQUE: 2
 };
 
-const FontWeight = {
+var FontWeight = {
     NORMAL : 0,
     BOLD : 1
 };
 
-const Format = {
+var Format = {
     ARGB32 : 0,
     RGB24 : 1,
     A8 : 2,
@@ -74,19 +74,19 @@ const Format = {
     RGB16_565: 5
 };
 
-const LineCap = {
+var LineCap = {
     BUTT: 0,
     ROUND: 1,
     SQUASH: 2
 };
 
-const LineJoin = {
+var LineJoin = {
     MITER: 0,
     ROUND: 1,
     BEVEL: 2
 };
 
-const Operator = {
+var Operator = {
     CLEAR: 0,
     SOURCE: 1,
     OVER: 2,
@@ -118,14 +118,14 @@ const Operator = {
     HSL_LUMINOSITY : 28
 };
 
-const PatternType = {
+var PatternType = {
     SOLID : 0,
     SURFACE : 1,
     LINEAR : 2,
     RADIAL : 3
 };
 
-const SurfaceType = {
+var SurfaceType = {
     IMAGE : 0,
     PDF : 1,
     PS : 2,
diff --git a/modules/gettext.js b/modules/gettext.js
index 67c4504..21648e1 100644
--- a/modules/gettext.js
+++ b/modules/gettext.js
@@ -35,7 +35,7 @@
 const GLib = imports.gi.GLib;
 const GjsPrivate = imports.gi.GjsPrivate;
 
-const LocaleCategory = GjsPrivate.LocaleCategory;
+var LocaleCategory = GjsPrivate.LocaleCategory;
 
 function setlocale(category, locale) {
     return GjsPrivate.setlocale(category, locale);
diff --git a/modules/signals.js b/modules/signals.js
index 8db97c2..2abeace 100644
--- a/modules/signals.js
+++ b/modules/signals.js
@@ -156,7 +156,7 @@ function addSignalMethods(proto) {
     _addSignalMethod(proto, "disconnectAll", _disconnectAll);
 }
 
-const WithSignals = new Lang.Interface({
+var WithSignals = new Lang.Interface({
     Name: 'WithSignals',
     connect: _connect,
     disconnect: _disconnect,


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