[gnome-shell] js: Check for this.constructor type instead of new.target
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] js: Check for this.constructor type instead of new.target
- Date: Sat, 27 Apr 2019 05:44:07 +0000 (UTC)
commit bbd3275dadeeec28bd47a7cbec1b72a5bec8212e
Author: Marco Trevisan (Treviño) <mail 3v1n0 net>
Date: Thu Apr 18 15:55:34 2019 -0500
js: Check for this.constructor type instead of new.target
Use more ES6-inspired check for classes initializations.
https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/503
js/ui/appDisplay.js | 4 ++--
js/ui/popupMenu.js | 4 ++--
js/ui/status/keyboard.js | 4 ++--
js/ui/status/network.js | 15 ++++++++-------
js/ui/workspace.js | 4 ++--
5 files changed, 16 insertions(+), 15 deletions(-)
---
diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js
index 1dd182b17..8981bbc96 100644
--- a/js/ui/appDisplay.js
+++ b/js/ui/appDisplay.js
@@ -98,8 +98,8 @@ function clamp(value, min, max) {
class BaseAppView {
constructor(params, gridParams) {
- if (new.target === BaseAppView)
- throw new TypeError('Cannot instantiate abstract class ' + new.target.name);
+ if (this.constructor === BaseAppView)
+ throw new TypeError(`Cannot instantiate abstract class ${this.constructor.name}`);
gridParams = Params.parse(gridParams, { xAlign: St.Align.MIDDLE,
columnLimit: MAX_COLUMNS,
diff --git a/js/ui/popupMenu.js b/js/ui/popupMenu.js
index d61d18792..6bbdd3eec 100644
--- a/js/ui/popupMenu.js
+++ b/js/ui/popupMenu.js
@@ -397,8 +397,8 @@ var PopupImageMenuItem = class extends PopupBaseMenuItem {
var PopupMenuBase = class {
constructor(sourceActor, styleClass) {
- if (new.target === PopupMenuBase)
- throw new TypeError('Cannot instantiate abstract class ' + new.target.name);
+ if (this.constructor === PopupMenuBase)
+ throw new TypeError(`Cannot instantiate abstract class ${this.constructor.name}`);
this.sourceActor = sourceActor;
this._parent = null;
diff --git a/js/ui/status/keyboard.js b/js/ui/status/keyboard.js
index d711a5453..274147fe4 100644
--- a/js/ui/status/keyboard.js
+++ b/js/ui/status/keyboard.js
@@ -125,8 +125,8 @@ class InputSourceSwitcher extends SwitcherPopup.SwitcherList {
var InputSourceSettings = class {
constructor() {
- if (new.target === InputSourceSettings)
- throw new TypeError('Cannot instantiate abstract class ' + new.target.name);
+ if (this.constructor === InputSourceSettings)
+ throw new TypeError(`Cannot instantiate abstract class ${this.constructor.name}`);
}
_emitInputSourcesChanged() {
diff --git a/js/ui/status/network.js b/js/ui/status/network.js
index e6551f217..9354183d3 100644
--- a/js/ui/status/network.js
+++ b/js/ui/status/network.js
@@ -167,10 +167,10 @@ var NMConnectionItem = class {
};
Signals.addSignalMethods(NMConnectionItem.prototype);
-var NMConnectionSection = class {
+var NMConnectionSection = class NMConnectionSection {
constructor(client) {
- if (new.target === NMConnectionSection)
- throw new TypeError('Cannot instantiate abstract type ' + new.target.name);
+ if (this.constructor === NMConnectionSection)
+ throw new TypeError(`Cannot instantiate abstract type ${this.constructor.name}`);
this._client = client;
@@ -297,12 +297,13 @@ var NMConnectionSection = class {
};
Signals.addSignalMethods(NMConnectionSection.prototype);
-var NMConnectionDevice = class extends NMConnectionSection {
+var NMConnectionDevice = class NMConnectionDevice extends NMConnectionSection {
constructor(client, device) {
- if (new.target === NMConnectionDevice)
- throw new TypeError('Cannot instantiate abstract type ' + new.target.name);
-
super(client);
+
+ if (this.constructor === NMConnectionDevice)
+ throw new TypeError(`Cannot instantiate abstract type ${this.constructor.name}`);
+
this._device = device;
this._description = '';
diff --git a/js/ui/workspace.js b/js/ui/workspace.js
index 9c5886144..cf52684c0 100644
--- a/js/ui/workspace.js
+++ b/js/ui/workspace.js
@@ -786,8 +786,8 @@ var WindowPositionFlags = {
var LayoutStrategy = class {
constructor(monitor, rowSpacing, columnSpacing) {
- if (new.target === LayoutStrategy)
- throw new TypeError('Cannot instantiate abstract type ' + new.target.name);
+ if (this.constructor === LayoutStrategy)
+ throw new TypeError(`Cannot instantiate abstract type ${this.constructor.name}`);
this._monitor = monitor;
this._rowSpacing = rowSpacing;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]