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 {
|
||||
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,
|
||||
|
@ -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;
|
||||
|
@ -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() {
|
||||
|
@ -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 = '';
|
||||
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user