[gjs] js: Stop using flags argument to String.replace()
- From: Philip Chimento <pchimento src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs] js: Stop using flags argument to String.replace()
- Date: Tue, 13 Jun 2017 05:25:36 +0000 (UTC)
commit 448263e5c07b6f6870efc0fda285c24ba4bff99d
Author: Philip Chimento <philip chimento gmail com>
Date: Sun Jun 11 23:23:46 2017 -0700
js: Stop using flags argument to String.replace()
This argument (e.g., str.replace('foo', 'bar', 'g')) was nonstandard and
is being removed in SpiderMonkey 52. Instead, we use a regular expression
literal, e.g. str.replace(/foo/g, 'bar').
In addition, tweak the test assertions in testGtk to test that the
provided children are neither null nor undefined, because more tests
should have failed on this.
https://bugzilla.gnome.org/show_bug.cgi?id=781429
installed-tests/js/testGtk.js | 12 ++++++------
modules/overrides/Gtk.js | 12 ++++++++----
modules/package.js | 2 +-
3 files changed, 15 insertions(+), 11 deletions(-)
---
diff --git a/installed-tests/js/testGtk.js b/installed-tests/js/testGtk.js
index 19ea06e..db97108 100755
--- a/installed-tests/js/testGtk.js
+++ b/installed-tests/js/testGtk.js
@@ -48,10 +48,10 @@ const MyComplexGtkSubclass = new Lang.Class({
testChildrenExist: function () {
this._internalLabel = this.get_template_child(MyComplexGtkSubclass, 'label-child');
- expect(this._internalLabel).not.toBeNull();
+ expect(this._internalLabel).toEqual(jasmine.anything());
- expect(this.label_child2).not.toBeNull();
- expect(this._internal_label_child).not.toBeNull();
+ expect(this.label_child2).toEqual(jasmine.anything());
+ expect(this._internal_label_child).toEqual(jasmine.anything());
}
});
@@ -68,9 +68,9 @@ const MyComplexGtkSubclassFromResource = new Lang.Class({
// },
testChildrenExist: function () {
- expect(this.label_child).not.toBeNull();
- expect(this.label_child2).not.toBeNull();
- expect(this._internal_label_child).not.toBeNull();
+ expect(this.label_child).toEqual(jasmine.anything());
+ expect(this.label_child2).toEqual(jasmine.anything());
+ expect(this._internal_label_child).toEqual(jasmine.anything());
}
});
diff --git a/modules/overrides/Gtk.js b/modules/overrides/Gtk.js
index 7090a77..1212de0 100644
--- a/modules/overrides/Gtk.js
+++ b/modules/overrides/Gtk.js
@@ -108,12 +108,16 @@ function _init() {
if (this.constructor.Template) {
let children = this.constructor.Children || [];
- for (let child of children)
- this[child.replace('-', '_', 'g')] = this.get_template_child(this.constructor, child);
+ for (let child of children) {
+ this[child.replace(/-/g, '_')] =
+ this.get_template_child(this.constructor, child);
+ }
let internalChildren = this.constructor.InternalChildren || [];
- for (let child of internalChildren)
- this['_' + child.replace('-', '_', 'g')] = this.get_template_child(this.constructor, child);
+ for (let child of internalChildren) {
+ this['_' + child.replace(/-/g, '_')] =
+ this.get_template_child(this.constructor, child);
+ }
}
};
}
diff --git a/modules/package.js b/modules/package.js
index 5a5cd22..2e6433f 100644
--- a/modules/package.js
+++ b/modules/package.js
@@ -67,7 +67,7 @@ function _runningFromMesonSource() {
}
function _makeNamePath(name) {
- return '/' + name.replace('.', '/', 'g');
+ return '/' + name.replace(/\./g, '/');
}
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]