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 {...defaults, ...params};
|
||||||
return Object.assign(defaultsCopy, params);
|
|
||||||
}
|
}
|
||||||
|
@ -38,11 +38,11 @@ export const BarLevel = GObject.registerClass({
|
|||||||
this._barLevelActiveBorderColor = null;
|
this._barLevelActiveBorderColor = null;
|
||||||
this._barLevelOverdriveBorderColor = null;
|
this._barLevelOverdriveBorderColor = null;
|
||||||
|
|
||||||
let defaultParams = {
|
super._init({
|
||||||
style_class: 'barlevel',
|
style_class: 'barlevel',
|
||||||
accessible_role: Atk.Role.LEVEL_BAR,
|
accessible_role: Atk.Role.LEVEL_BAR,
|
||||||
};
|
...params,
|
||||||
super._init(Object.assign(defaultParams, params));
|
});
|
||||||
this.connect('notify::allocation', () => {
|
this.connect('notify::allocation', () => {
|
||||||
this._barLevelWidth = this.allocation.get_width();
|
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.ellipsize = Pango.EllipsizeMode.NONE;
|
||||||
this._description.clutter_text.line_wrap = true;
|
this._description.clutter_text.line_wrap = true;
|
||||||
|
|
||||||
let defaultParams = {
|
super._init({
|
||||||
style_class: 'message-dialog-content',
|
style_class: 'message-dialog-content',
|
||||||
x_expand: true,
|
x_expand: true,
|
||||||
vertical: true,
|
vertical: true,
|
||||||
};
|
...params,
|
||||||
super._init(Object.assign(defaultParams, params));
|
});
|
||||||
|
|
||||||
this.connect('notify::size', this._updateTitleStyle.bind(this));
|
this.connect('notify::size', this._updateTitleStyle.bind(this));
|
||||||
this.connect('destroy', this._onDestroy.bind(this));
|
this.connect('destroy', this._onDestroy.bind(this));
|
||||||
@ -269,12 +269,12 @@ export const ListSection = GObject.registerClass({
|
|||||||
child: this.list,
|
child: this.list,
|
||||||
});
|
});
|
||||||
|
|
||||||
let defaultParams = {
|
super._init({
|
||||||
style_class: 'dialog-list',
|
style_class: 'dialog-list',
|
||||||
x_expand: true,
|
x_expand: true,
|
||||||
vertical: true,
|
vertical: true,
|
||||||
};
|
...params,
|
||||||
super._init(Object.assign(defaultParams, params));
|
});
|
||||||
|
|
||||||
this.label_actor = this._title;
|
this.label_actor = this._title;
|
||||||
this.add_child(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._title);
|
||||||
textLayout.add_child(this._description);
|
textLayout.add_child(this._description);
|
||||||
|
|
||||||
let defaultParams = {style_class: 'dialog-list-item'};
|
super._init({
|
||||||
super._init(Object.assign(defaultParams, params));
|
style_class: 'dialog-list-item',
|
||||||
|
...params,
|
||||||
|
});
|
||||||
|
|
||||||
this.label_actor = this._title;
|
this.label_actor = this._title;
|
||||||
this.add_child(this._iconActorBin);
|
this.add_child(this._iconActorBin);
|
||||||
|
@ -795,13 +795,14 @@ class _Draggable extends Signals.EventEmitter {
|
|||||||
this._animationInProgress = true;
|
this._animationInProgress = true;
|
||||||
|
|
||||||
// start the animation
|
// start the animation
|
||||||
this._dragActor.ease(Object.assign(params, {
|
this._dragActor.ease({
|
||||||
|
...params,
|
||||||
opacity: this._dragOrigOpacity,
|
opacity: this._dragOrigOpacity,
|
||||||
mode: Clutter.AnimationMode.EASE_OUT_QUAD,
|
mode: Clutter.AnimationMode.EASE_OUT_QUAD,
|
||||||
onComplete: () => {
|
onComplete: () => {
|
||||||
this._onAnimationComplete(this._dragActor, eventTime);
|
this._onAnimationComplete(this._dragActor, eventTime);
|
||||||
},
|
},
|
||||||
}));
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
_finishAnimation() {
|
_finishAnimation() {
|
||||||
|
@ -211,13 +211,14 @@ function _easeActorProperty(actor, propName, target, params) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let pspec = actor.find_property(propName);
|
let pspec = actor.find_property(propName);
|
||||||
let transition = new Clutter.PropertyTransition(Object.assign({
|
let transition = new Clutter.PropertyTransition({
|
||||||
property_name: propName,
|
property_name: propName,
|
||||||
interval: new Clutter.Interval({value_type: pspec.value_type}),
|
interval: new Clutter.Interval({value_type: pspec.value_type}),
|
||||||
remove_on_complete: true,
|
remove_on_complete: true,
|
||||||
repeat_count: repeatCount,
|
repeat_count: repeatCount,
|
||||||
auto_reverse: autoReverse,
|
auto_reverse: autoReverse,
|
||||||
}, params));
|
...params,
|
||||||
|
});
|
||||||
actor.add_transition(propName, transition);
|
actor.add_transition(propName, transition);
|
||||||
|
|
||||||
transition.set_to(target);
|
transition.set_to(target);
|
||||||
|
@ -209,12 +209,13 @@ export const Lightbox = GObject.registerClass({
|
|||||||
'@effects.radial.brightness', VIGNETTE_BRIGHTNESS, easeProps);
|
'@effects.radial.brightness', VIGNETTE_BRIGHTNESS, easeProps);
|
||||||
this.ease_property(
|
this.ease_property(
|
||||||
'@effects.radial.sharpness', VIGNETTE_SHARPNESS,
|
'@effects.radial.sharpness', VIGNETTE_SHARPNESS,
|
||||||
Object.assign({onComplete}, easeProps));
|
{onComplete, ...easeProps});
|
||||||
} else {
|
} else {
|
||||||
this.ease(Object.assign(easeProps, {
|
this.ease({
|
||||||
|
...easeProps,
|
||||||
opacity: 255 * this._fadeFactor,
|
opacity: 255 * this._fadeFactor,
|
||||||
onComplete,
|
onComplete,
|
||||||
}));
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -235,9 +236,9 @@ export const Lightbox = GObject.registerClass({
|
|||||||
this.ease_property(
|
this.ease_property(
|
||||||
'@effects.radial.brightness', 1.0, easeProps);
|
'@effects.radial.brightness', 1.0, easeProps);
|
||||||
this.ease_property(
|
this.ease_property(
|
||||||
'@effects.radial.sharpness', 0.0, Object.assign({onComplete}, easeProps));
|
'@effects.radial.sharpness', 0.0, {onComplete, ...easeProps});
|
||||||
} else {
|
} 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(
|
export const CapsLockWarning = GObject.registerClass(
|
||||||
class CapsLockWarning extends St.Label {
|
class CapsLockWarning extends St.Label {
|
||||||
_init(params) {
|
_init(params) {
|
||||||
let defaultParams = {style_class: 'caps-lock-warning-label'};
|
super._init({
|
||||||
super._init(Object.assign(defaultParams, params));
|
style_class: 'caps-lock-warning-label',
|
||||||
|
...params,
|
||||||
|
});
|
||||||
|
|
||||||
this.text = _('Caps lock is on.');
|
this.text = _('Caps lock is on.');
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user