SwitcherPopup: Check for type using constructor
Classes that are sub-classes of GObject don't use a constructor per se, so we can't check for new.target (as this is undefined) in _init. Then compare the current constructor name instead. https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/503
This commit is contained in:
parent
a63ba61194
commit
3c54e863e6
@ -33,8 +33,8 @@ function primaryModifier(mask) {
|
|||||||
var SwitcherPopup = GObject.registerClass(
|
var SwitcherPopup = GObject.registerClass(
|
||||||
class SwitcherPopup extends St.Widget {
|
class SwitcherPopup extends St.Widget {
|
||||||
_init(items) {
|
_init(items) {
|
||||||
if (new.target === SwitcherPopup)
|
if (this.constructor.name === SwitcherPopup.prototype.constructor.name)
|
||||||
throw new TypeError('Cannot instantiate abstract class ' + new.target.name);
|
throw new TypeError(`Cannot instantiate abstract class ${this.constructor.name}`);
|
||||||
|
|
||||||
super._init({ style_class: 'switcher-popup',
|
super._init({ style_class: 'switcher-popup',
|
||||||
reactive: true,
|
reactive: true,
|
||||||
|
Loading…
Reference in New Issue
Block a user