chore: unify the naming of changedProperties param (#620)

This commit is contained in:
Sławek Amielucha 2020-03-02 14:35:01 +01:00 committed by Thomas Allmer
parent 67a42c032e
commit ad1e828d51
15 changed files with 73 additions and 67 deletions

View file

@ -217,8 +217,8 @@ export class LionCalendar extends LocalizeMixin(LitElement) {
this.__addEventForKeyboardNavigation();
}
updated(changed) {
if (changed.has('__focusedDate') && this.__focusedDate) {
updated(changedProperties) {
if (changedProperties.has('__focusedDate') && this.__focusedDate) {
this.focusCentralDate();
}
}

View file

@ -62,18 +62,18 @@ export const ChoiceInputMixin = superclass =>
}
}
firstUpdated(c) {
super.firstUpdated(c);
if (c.has('checked')) {
firstUpdated(changedProperties) {
super.firstUpdated(changedProperties);
if (changedProperties.has('checked')) {
// Here we set the initial value for our [slot=input] content,
// which has been set by our SlotMixin
this.__syncCheckedToInputElement();
}
}
updated(c) {
super.updated(c);
if (c.has('modelValue')) {
updated(changedProperties) {
super.updated(changedProperties);
if (changedProperties.has('modelValue')) {
this.__syncCheckedToInputElement();
}
}

View file

@ -102,10 +102,10 @@ export const FormControlMixin = dedupeMixin(
};
}
updated(changedProps) {
super.updated(changedProps);
updated(changedProperties) {
super.updated(changedProperties);
if (changedProps.has('_ariaLabelledNodes')) {
if (changedProperties.has('_ariaLabelledNodes')) {
this.__reflectAriaAttr(
'aria-labelledby',
this._ariaLabelledNodes,
@ -113,7 +113,7 @@ export const FormControlMixin = dedupeMixin(
);
}
if (changedProps.has('_ariaDescribedNodes')) {
if (changedProperties.has('_ariaDescribedNodes')) {
this.__reflectAriaAttr(
'aria-describedby',
this._ariaDescribedNodes,
@ -121,11 +121,11 @@ export const FormControlMixin = dedupeMixin(
);
}
if (changedProps.has('label')) {
if (changedProperties.has('label')) {
this._onLabelChanged({ label: this.label });
}
if (changedProps.has('helpText')) {
if (changedProperties.has('helpText')) {
this._onHelpTextChanged({ helpText: this.helpText });
}
}

View file

@ -93,8 +93,8 @@ export class LionField extends FormControlMixin(
this.submitted = false;
}
firstUpdated(c) {
super.firstUpdated(c);
firstUpdated(changedProperties) {
super.firstUpdated(changedProperties);
this._initialModelValue = this.modelValue;
}
@ -118,19 +118,19 @@ export class LionField extends FormControlMixin(
this._inputNode.removeEventListener('change', this._onChange);
}
updated(changedProps) {
super.updated(changedProps);
updated(changedProperties) {
super.updated(changedProperties);
if (changedProps.has('disabled')) {
if (changedProperties.has('disabled')) {
this._inputNode.disabled = this.disabled;
this.validate();
}
if (changedProps.has('name')) {
if (changedProperties.has('name')) {
this._inputNode.name = this.name;
}
if (changedProps.has('autocomplete')) {
if (changedProperties.has('autocomplete')) {
this._inputNode.autocomplete = this.autocomplete;
}
}

View file

@ -145,10 +145,10 @@ export const FormGroupMixin = dedupeMixin(
});
}
updated(changedProps) {
super.updated(changedProps);
updated(changedProperties) {
super.updated(changedProperties);
if (changedProps.has('disabled')) {
if (changedProperties.has('disabled')) {
if (this.disabled) {
this.__requestChildrenToBeDisabled();
} else {
@ -156,7 +156,7 @@ export const FormGroupMixin = dedupeMixin(
}
}
if (changedProps.has('focused')) {
if (changedProperties.has('focused')) {
if (this.focused === true) {
this.__setupOutsideClickHandling();
}

View file

@ -37,8 +37,8 @@ export class HelperOutput extends LitElement {
];
}
firstUpdated(c) {
super.firstUpdated(c);
firstUpdated(changedProperties) {
super.firstUpdated(changedProperties);
if (!this.field) {
// Fuzzy logic, but... practical
const prev = this.previousElementSibling;

View file

@ -87,9 +87,9 @@ export class LionInputAmount extends LocalizeMixin(LionInput) {
}
}
updated(changedProps) {
super.updated(changedProps);
if (changedProps.has('currency')) {
updated(changedProperties) {
super.updated(changedProperties);
if (changedProperties.has('currency')) {
this._onCurrencyChanged({ currency: this.currency });
}
}

View file

@ -23,9 +23,9 @@ export class LionInputDate extends LocalizeMixin(LionInput) {
this.defaultValidators.push(new IsDate());
}
updated(c) {
super.updated(c);
if (c.has('locale')) {
updated(changedProperties) {
super.updated(changedProperties);
if (changedProperties.has('locale')) {
this._calculateValues();
}
}

View file

@ -178,22 +178,22 @@ export class LionInputDatepicker extends OverlayMixin(LionInputDate) {
}
}
firstUpdated(c) {
super.firstUpdated(c);
firstUpdated(changedProperties) {
super.firstUpdated(changedProperties);
this.__toggleInvokerDisabled();
}
/**
* @override
* @param {Map} c - changed properties
* @param {Map} changedProperties - changed properties
*/
updated(c) {
super.updated(c);
if (c.has('validators')) {
updated(changedProperties) {
super.updated(changedProperties);
if (changedProperties.has('validators')) {
const validators = [...(this.validators || [])];
this.__syncDisabledDates(validators);
}
if (c.has('label')) {
if (changedProperties.has('label')) {
this.calendarHeading = this.calendarHeading || this.label;
}
}

View file

@ -60,17 +60,17 @@ export class LionInput extends LionField {
}
}
firstUpdated(c) {
super.firstUpdated(c);
firstUpdated(changedProperties) {
super.firstUpdated(changedProperties);
this.__delegateReadOnly();
}
updated(changedProps) {
super.updated(changedProps);
if (changedProps.has('type')) {
updated(changedProperties) {
super.updated(changedProperties);
if (changedProperties.has('type')) {
this._inputNode.type = this.type;
}
if (changedProps.has('placeholder')) {
if (changedProperties.has('placeholder')) {
this._inputNode.placeholder = this.placeholder;
}
}

View file

@ -200,8 +200,8 @@ export class LionSelectRich extends ChoiceGroupMixin(
this.__teardownListboxNode();
}
firstUpdated(c) {
super.firstUpdated(c);
firstUpdated(changedProperties) {
super.firstUpdated(changedProperties);
this.__setupOverlay();
this.__setupInvokerNode();
this.__setupListboxNode();
@ -245,10 +245,10 @@ export class LionSelectRich extends ChoiceGroupMixin(
`;
}
updated(changedProps) {
super.updated(changedProps);
updated(changedProperties) {
super.updated(changedProperties);
if (changedProps.has('disabled')) {
if (changedProperties.has('disabled')) {
if (this.disabled) {
this._invokerNode.makeRequestToBeDisabled();
this.__requestOptionsToBeDisabled();
@ -259,21 +259,21 @@ export class LionSelectRich extends ChoiceGroupMixin(
}
if (this._inputNode && this._invokerNode) {
if (changedProps.has('_ariaLabelledNodes')) {
if (changedProperties.has('_ariaLabelledNodes')) {
this._invokerNode.setAttribute(
'aria-labelledby',
`${this._inputNode.getAttribute('aria-labelledby')} ${this._invokerNode.id}`,
);
}
if (changedProps.has('_ariaDescribedNodes')) {
if (changedProperties.has('_ariaDescribedNodes')) {
this._invokerNode.setAttribute(
'aria-describedby',
this._inputNode.getAttribute('aria-describedby'),
);
}
if (changedProps.has('showsFeedbackFor')) {
if (changedProperties.has('showsFeedbackFor')) {
// The ValidateMixin sets aria-invalid on the inputNode, but in this component we also need it on the invoker
this._invokerNode.setAttribute('aria-invalid', this._hasFeedbackVisibleFor('error'));
}

View file

@ -31,10 +31,13 @@ export class LionSteps extends LitElement {
};
}
updated(changedProps) {
super.updated(changedProps);
if (changedProps.has('current')) {
this._onCurrentChanged({ current: this.current }, { current: changedProps.get('current') });
updated(changedProperties) {
super.updated(changedProperties);
if (changedProperties.has('current')) {
this._onCurrentChanged(
{ current: this.current },
{ current: changedProperties.get('current') },
);
}
}

View file

@ -188,8 +188,8 @@ export const ValidateMixin = dedupeMixin(
await import('../lion-validation-feedback.js');
}
firstUpdated(c) {
super.firstUpdated(c);
firstUpdated(changedProperties) {
super.firstUpdated(changedProperties);
this.__validateInitialized = true;
this.validate();
this._loadFeedbackComponent();
@ -591,10 +591,13 @@ export const ValidateMixin = dedupeMixin(
);
}
updated(c) {
super.updated(c);
updated(changedProperties) {
super.updated(changedProperties);
if (c.has('shouldShowFeedbackFor') || c.has('hasFeedbackFor')) {
if (
changedProperties.has('shouldShowFeedbackFor') ||
changedProperties.has('hasFeedbackFor')
) {
this.showsFeedbackFor = this.constructor.validationTypes
.map(type => (this._hasFeedbackVisibleFor(type) ? type : undefined))
.filter(_ => !!_);

View file

@ -25,8 +25,8 @@ export const SyncUpdatableMixin = dedupeMixin(
this.__SyncUpdatableNamespace = {};
}
firstUpdated(c) {
super.firstUpdated(c);
firstUpdated(changedProperties) {
super.firstUpdated(changedProperties);
this.__SyncUpdatableNamespace.connected = true;
this.__syncUpdatableInitialize();
}

View file

@ -27,8 +27,8 @@ describe('SyncUpdatableMixin', () => {
this.propB = 'init-b';
}
firstUpdated(c) {
super.firstUpdated(c);
firstUpdated(changedProperties) {
super.firstUpdated(changedProperties);
hasCalledFirstUpdated = true;
}