cleanup: Use spread properties instead of Object.assign()
It's more concise and has been around long enough to embrace it. Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3196>
This commit is contained in:
parent
5ce991749d
commit
8eec7ac3f4
@ -25,6 +25,5 @@ export function parse(params = {}, defaults, allowExtras) {
|
||||
}
|
||||
}
|
||||
|
||||
let defaultsCopy = Object.assign({}, defaults);
|
||||
return Object.assign(defaultsCopy, params);
|
||||
return {...defaults, ...params};
|
||||
}
|
||||
|
@ -38,11 +38,11 @@ export const BarLevel = GObject.registerClass({
|
||||
this._barLevelActiveBorderColor = null;
|
||||
this._barLevelOverdriveBorderColor = null;
|
||||
|
||||
let defaultParams = {
|
||||
super._init({
|
||||
style_class: 'barlevel',
|
||||
accessible_role: Atk.Role.LEVEL_BAR,
|
||||
};
|
||||
super._init(Object.assign(defaultParams, params));
|
||||
...params,
|
||||
});
|
||||
this.connect('notify::allocation', () => {
|
||||
this._barLevelWidth = this.allocation.get_width();
|
||||
});
|
||||
|
@ -176,12 +176,12 @@ export const MessageDialogContent = GObject.registerClass({
|
||||
this._description.clutter_text.ellipsize = Pango.EllipsizeMode.NONE;
|
||||
this._description.clutter_text.line_wrap = true;
|
||||
|
||||
let defaultParams = {
|
||||
super._init({
|
||||
style_class: 'message-dialog-content',
|
||||
x_expand: true,
|
||||
vertical: true,
|
||||
};
|
||||
super._init(Object.assign(defaultParams, params));
|
||||
...params,
|
||||
});
|
||||
|
||||
this.connect('notify::size', this._updateTitleStyle.bind(this));
|
||||
this.connect('destroy', this._onDestroy.bind(this));
|
||||
@ -269,12 +269,12 @@ export const ListSection = GObject.registerClass({
|
||||
child: this.list,
|
||||
});
|
||||
|
||||
let defaultParams = {
|
||||
super._init({
|
||||
style_class: 'dialog-list',
|
||||
x_expand: true,
|
||||
vertical: true,
|
||||
};
|
||||
super._init(Object.assign(defaultParams, params));
|
||||
...params,
|
||||
});
|
||||
|
||||
this.label_actor = this._title;
|
||||
this.add_child(this._title);
|
||||
@ -327,8 +327,10 @@ export const ListSectionItem = GObject.registerClass({
|
||||
textLayout.add_child(this._title);
|
||||
textLayout.add_child(this._description);
|
||||
|
||||
let defaultParams = {style_class: 'dialog-list-item'};
|
||||
super._init(Object.assign(defaultParams, params));
|
||||
super._init({
|
||||
style_class: 'dialog-list-item',
|
||||
...params,
|
||||
});
|
||||
|
||||
this.label_actor = this._title;
|
||||
this.add_child(this._iconActorBin);
|
||||
|
@ -795,13 +795,14 @@ class _Draggable extends Signals.EventEmitter {
|
||||
this._animationInProgress = true;
|
||||
|
||||
// start the animation
|
||||
this._dragActor.ease(Object.assign(params, {
|
||||
this._dragActor.ease({
|
||||
...params,
|
||||
opacity: this._dragOrigOpacity,
|
||||
mode: Clutter.AnimationMode.EASE_OUT_QUAD,
|
||||
onComplete: () => {
|
||||
this._onAnimationComplete(this._dragActor, eventTime);
|
||||
},
|
||||
}));
|
||||
});
|
||||
}
|
||||
|
||||
_finishAnimation() {
|
||||
|
@ -211,13 +211,14 @@ function _easeActorProperty(actor, propName, target, params) {
|
||||
}
|
||||
|
||||
let pspec = actor.find_property(propName);
|
||||
let transition = new Clutter.PropertyTransition(Object.assign({
|
||||
let transition = new Clutter.PropertyTransition({
|
||||
property_name: propName,
|
||||
interval: new Clutter.Interval({value_type: pspec.value_type}),
|
||||
remove_on_complete: true,
|
||||
repeat_count: repeatCount,
|
||||
auto_reverse: autoReverse,
|
||||
}, params));
|
||||
...params,
|
||||
});
|
||||
actor.add_transition(propName, transition);
|
||||
|
||||
transition.set_to(target);
|
||||
|
@ -209,12 +209,13 @@ export const Lightbox = GObject.registerClass({
|
||||
'@effects.radial.brightness', VIGNETTE_BRIGHTNESS, easeProps);
|
||||
this.ease_property(
|
||||
'@effects.radial.sharpness', VIGNETTE_SHARPNESS,
|
||||
Object.assign({onComplete}, easeProps));
|
||||
{onComplete, ...easeProps});
|
||||
} else {
|
||||
this.ease(Object.assign(easeProps, {
|
||||
this.ease({
|
||||
...easeProps,
|
||||
opacity: 255 * this._fadeFactor,
|
||||
onComplete,
|
||||
}));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -235,9 +236,9 @@ export const Lightbox = GObject.registerClass({
|
||||
this.ease_property(
|
||||
'@effects.radial.brightness', 1.0, easeProps);
|
||||
this.ease_property(
|
||||
'@effects.radial.sharpness', 0.0, Object.assign({onComplete}, easeProps));
|
||||
'@effects.radial.sharpness', 0.0, {onComplete, ...easeProps});
|
||||
} else {
|
||||
this.ease(Object.assign(easeProps, {opacity: 0, onComplete}));
|
||||
this.ease({...easeProps, opacity: 0, onComplete});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -168,8 +168,10 @@ export function addContextMenu(entry, params) {
|
||||
export const CapsLockWarning = GObject.registerClass(
|
||||
class CapsLockWarning extends St.Label {
|
||||
_init(params) {
|
||||
let defaultParams = {style_class: 'caps-lock-warning-label'};
|
||||
super._init(Object.assign(defaultParams, params));
|
||||
super._init({
|
||||
style_class: 'caps-lock-warning-label',
|
||||
...params,
|
||||
});
|
||||
|
||||
this.text = _('Caps lock is on.');
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user