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
This commit is contained in:
parent
3a3f9aa008
commit
bbd3275dad
@ -98,8 +98,8 @@ function clamp(value, min, max) {
|
|||||||
|
|
||||||
class BaseAppView {
|
class BaseAppView {
|
||||||
constructor(params, gridParams) {
|
constructor(params, gridParams) {
|
||||||
if (new.target === BaseAppView)
|
if (this.constructor === BaseAppView)
|
||||||
throw new TypeError('Cannot instantiate abstract class ' + new.target.name);
|
throw new TypeError(`Cannot instantiate abstract class ${this.constructor.name}`);
|
||||||
|
|
||||||
gridParams = Params.parse(gridParams, { xAlign: St.Align.MIDDLE,
|
gridParams = Params.parse(gridParams, { xAlign: St.Align.MIDDLE,
|
||||||
columnLimit: MAX_COLUMNS,
|
columnLimit: MAX_COLUMNS,
|
||||||
|
@ -397,8 +397,8 @@ var PopupImageMenuItem = class extends PopupBaseMenuItem {
|
|||||||
|
|
||||||
var PopupMenuBase = class {
|
var PopupMenuBase = class {
|
||||||
constructor(sourceActor, styleClass) {
|
constructor(sourceActor, styleClass) {
|
||||||
if (new.target === PopupMenuBase)
|
if (this.constructor === PopupMenuBase)
|
||||||
throw new TypeError('Cannot instantiate abstract class ' + new.target.name);
|
throw new TypeError(`Cannot instantiate abstract class ${this.constructor.name}`);
|
||||||
|
|
||||||
this.sourceActor = sourceActor;
|
this.sourceActor = sourceActor;
|
||||||
this._parent = null;
|
this._parent = null;
|
||||||
|
@ -125,8 +125,8 @@ class InputSourceSwitcher extends SwitcherPopup.SwitcherList {
|
|||||||
|
|
||||||
var InputSourceSettings = class {
|
var InputSourceSettings = class {
|
||||||
constructor() {
|
constructor() {
|
||||||
if (new.target === InputSourceSettings)
|
if (this.constructor === InputSourceSettings)
|
||||||
throw new TypeError('Cannot instantiate abstract class ' + new.target.name);
|
throw new TypeError(`Cannot instantiate abstract class ${this.constructor.name}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
_emitInputSourcesChanged() {
|
_emitInputSourcesChanged() {
|
||||||
|
@ -167,10 +167,10 @@ var NMConnectionItem = class {
|
|||||||
};
|
};
|
||||||
Signals.addSignalMethods(NMConnectionItem.prototype);
|
Signals.addSignalMethods(NMConnectionItem.prototype);
|
||||||
|
|
||||||
var NMConnectionSection = class {
|
var NMConnectionSection = class NMConnectionSection {
|
||||||
constructor(client) {
|
constructor(client) {
|
||||||
if (new.target === NMConnectionSection)
|
if (this.constructor === NMConnectionSection)
|
||||||
throw new TypeError('Cannot instantiate abstract type ' + new.target.name);
|
throw new TypeError(`Cannot instantiate abstract type ${this.constructor.name}`);
|
||||||
|
|
||||||
this._client = client;
|
this._client = client;
|
||||||
|
|
||||||
@ -297,12 +297,13 @@ var NMConnectionSection = class {
|
|||||||
};
|
};
|
||||||
Signals.addSignalMethods(NMConnectionSection.prototype);
|
Signals.addSignalMethods(NMConnectionSection.prototype);
|
||||||
|
|
||||||
var NMConnectionDevice = class extends NMConnectionSection {
|
var NMConnectionDevice = class NMConnectionDevice extends NMConnectionSection {
|
||||||
constructor(client, device) {
|
constructor(client, device) {
|
||||||
if (new.target === NMConnectionDevice)
|
|
||||||
throw new TypeError('Cannot instantiate abstract type ' + new.target.name);
|
|
||||||
|
|
||||||
super(client);
|
super(client);
|
||||||
|
|
||||||
|
if (this.constructor === NMConnectionDevice)
|
||||||
|
throw new TypeError(`Cannot instantiate abstract type ${this.constructor.name}`);
|
||||||
|
|
||||||
this._device = device;
|
this._device = device;
|
||||||
this._description = '';
|
this._description = '';
|
||||||
|
|
||||||
|
@ -786,8 +786,8 @@ var WindowPositionFlags = {
|
|||||||
|
|
||||||
var LayoutStrategy = class {
|
var LayoutStrategy = class {
|
||||||
constructor(monitor, rowSpacing, columnSpacing) {
|
constructor(monitor, rowSpacing, columnSpacing) {
|
||||||
if (new.target === LayoutStrategy)
|
if (this.constructor === LayoutStrategy)
|
||||||
throw new TypeError('Cannot instantiate abstract type ' + new.target.name);
|
throw new TypeError(`Cannot instantiate abstract type ${this.constructor.name}`);
|
||||||
|
|
||||||
this._monitor = monitor;
|
this._monitor = monitor;
|
||||||
this._rowSpacing = rowSpacing;
|
this._rowSpacing = rowSpacing;
|
||||||
|
Loading…
Reference in New Issue
Block a user