CyclerPopup: 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:
Marco Trevisan (Treviño) 2019-04-18 15:50:21 -05:00
parent 3c54e863e6
commit 3a3f9aa008

View File

@ -477,8 +477,8 @@ var CyclerList = GObject.registerClass({
var CyclerPopup = GObject.registerClass(
class CyclerPopup extends SwitcherPopup.SwitcherPopup {
_init() {
if (new.target === CyclerPopup)
throw new TypeError('Cannot instantiate abstract class ' + new.target.name);
if (this.constructor.name === CyclerPopup.prototype.constructor.name)
throw new TypeError(`Cannot instantiate abstract class ${this.constructor.name}`);
super._init();