cleanup: Use Function.prototype.bind()

When not using arrow notation with anonymous functions, we use Lang.bind()
to bind `this` to named callbacks. However since ES5, this functionality
is already provided by Function.prototype.bind() - in fact, Lang.bind()
itself uses it when no extra arguments are specified. Just use the built-in
function directly where possible, and use arrow notation in the few places
where we pass additional arguments.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/23
This commit is contained in:
Florian Müllner
2017-12-02 01:27:35 +01:00
committed by Florian Müllner
parent 213e38c2ef
commit 3b1330880f
100 changed files with 1021 additions and 999 deletions

View File

@ -14,7 +14,7 @@ var Animation = new Lang.Class({
_init(file, width, height, speed) {
this.actor = new St.Bin();
this.actor.connect('destroy', Lang.bind(this, this._onDestroy));
this.actor.connect('destroy', this._onDestroy.bind(this));
this._speed = speed;
this._isLoaded = false;
@ -24,7 +24,7 @@ var Animation = new Lang.Class({
let scaleFactor = St.ThemeContext.get_for_stage(global.stage).scale_factor;
this._animations = St.TextureCache.get_default().load_sliced_image (file, width, height, scaleFactor,
Lang.bind(this, this._animationsLoaded));
this._animationsLoaded.bind(this));
this.actor.set_child(this._animations);
},
@ -33,7 +33,7 @@ var Animation = new Lang.Class({
if (this._frame == 0)
this._showFrame(0);
this._timeoutId = GLib.timeout_add(GLib.PRIORITY_LOW, this._speed, Lang.bind(this, this._update));
this._timeoutId = GLib.timeout_add(GLib.PRIORITY_LOW, this._speed, this._update.bind(this));
GLib.Source.set_name_by_id(this._timeoutId, '[gnome-shell] this._update');
}