Skip to content

feat: add DelegateStateMixin and make other mixins use it - #2455

Merged
web-padawan merged 2 commits into
masterfrom
feat/delegate-props-mixin
Sep 6, 2021
Merged

web-padawan merged 2 commits into
masterfrom
feat/delegate-props-mixin

Conversation

@vursen

@vursen vursen commented Sep 6, 2021 •

Copy link
Copy Markdown
Contributor

Description

At this moment, there is only ForwardInputPropsMixin for delegation purposes and the problem is that it doesn't just delegate attributes to an input element but also defines new properties for a component, such as placeholder for example.

There is coming CheckedMixin (see #2210) and it needs to delegate some of its attributes to the checkbox input as well. However, it doesn't need the placeholder attribute.

Therefore it makes sense to have an abstract mixin that is only aimed at the delegation of a set of attributes/properties to a target element. The target element should be defined by the client component.

... so what was done in the PR?

  • Introduced an abstract DelegateStateMixin that is supposed to be used for the delegation of attributes and properties from the host element to a target element (it was a part of ForwardInputPropsMixin before).
  • Renamed ForwardInputPropsMixin to DelegateInputStateMixin that now extends DelegateStateMixin.
  • Refactored InputConstraintsMixin to make it extend DelegateInputStateMixin and not the other way around (as it was before).
  • Most of the initialization logic was moved to ready() from connectedCallback() to initialize the mixins in the same order they are applied.

Part of #2210

Type of change

  • Internal change

Checklist

  • I have read the contribution guide: https://vaadin.com/docs-beta/latest/guide/contributing/overview/
  • I have added a description following the guideline.
  • The issue is created in the corresponding repository and I have referenced it.
  • I have added tests to ensure my change is effective and works as intended.
  • New and existing tests are passing locally with my change.
  • I have performed self-review and corrected misspellings.

@vursen
vursen requested review from web-padawan and removed request for web-padawan September 6, 2021 08:16
Comment thread packages/field-base/src/slot-mixin.js Resolved
@vursen
vursen force-pushed the feat/delegate-props-mixin branch 2 times, most recently from 101d4e9 to dd834bf Compare September 6, 2021 10:19
@vursen
vursen marked this pull request as ready for review September 6, 2021 10:21
@vursen
vursen force-pushed the feat/delegate-props-mixin branch from dd834bf to 48f0e11 Compare September 6, 2021 10:25
Comment thread packages/field-base/index.d.ts Resolved
Comment thread packages/field-base/index.js Resolved
@sonarqubecloud

sonarqubecloud Bot commented Sep 6, 2021

Copy link
Copy Markdown

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@web-padawan web-padawan changed the title refactor: add DelegateStateMixin and make other mixins use it feat: add DelegateStateMixin and make other mixins use it Sep 6, 2021
@vaadin-bot

Copy link
Copy Markdown
Collaborator

This ticket/PR has been released with platform 22.0.0.alpha3 and is also targeting the upcoming stable 22.0.0 version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants