Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

johnjenkins
Copy link
Contributor

@johnjenkins johnjenkins commented Sep 1, 2025

What is the current behavior?

A Stencil component can only extend from another, single class.

Dynamic, mixin style behaviour (as outlined here) being hard in Stencil as it relies on static analysis to extract component meta.

GitHub Issue Number: #3162 I think?

What is the new behavior?

A new core Mixin helper function to extend from. This provides a predictable pattern to pull apart for Static analysis.
The function accepts mixin-factory-functions as arguments and the end result is typed appropriately with all relevant Stencil-related meta being merged correctly.

e.g.

const AWrap = (Base) => {class A extends Base { propA = A }; return A;}
const BWrap = (Base) => {class B extends Base { propB = B }; return B;}
const CWrap = (Base) => {class C extends Base { propC = C }; return C;}

@Component(...) 
class X extends Mixin(AWrap, BWrap, CWrap) {
   render() { return <div>{this.propA} {this.propB} {this.propC}</div>; }
}

Documentation

stenciljs/site#1545

Does this introduce a breaking change?

  • Yes
  • No

Testing

  • spec tests
  • component / wdio tests

Other information

@johnjenkins
Copy link
Contributor Author

johnjenkins commented Sep 1, 2025

@danielleroux - turns out the initial pass wasn't too tricky :)

*edit - was much more tricky than the first pass :D

@johnjenkins johnjenkins marked this pull request as ready for review September 12, 2025 18:42
@johnjenkins johnjenkins requested a review from a team as a code owner September 12, 2025 18:42
@johnjenkins johnjenkins merged commit 08f6583 into main Sep 12, 2025
69 checks passed
@johnjenkins johnjenkins deleted the feat-mixin branch September 12, 2025 23:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant