Package Exports
- @lion/core
- @lion/core/src/CssClassMixin.js
- @lion/core/src/ElementMixin.js
- @lion/core/src/EventMixin.js
- @lion/core/src/LionLitElement.js
- @lion/core/src/ObserverMixin.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@lion/core) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Core
🛠 Status: Pilot Phase
Lion Web Components are still in an early alpha stage; they should not be considered production ready yet.
The goal of our pilot phase is to gather feedback from a private group of users. Therefore, during this phase, we kindly ask you to:
- not publicly promote or link us yet: (no tweets, blog posts or other forms of communication about Lion Web Components)
- not publicly promote or link products derived from/based on Lion Web Components
As soon as Pilot Phase ends we will let you know (feel free to subscribe to this issue https://github.com/ing-bank/lion/issues/1)
Deprecations
The following files/features are deprecated
- CssClassMixin
- DomHelpersMixin (only $$id, $$slot is deprecated)
- ElementMixin
- EventMixin
- ObserverMixin
- lit-html.js
Deduping of mixins
Why is deduping of mixins necessary?
Imagine you are developing web components and creating ES classes for Custom Elements. You have two generic mixins (let's say M1 and M2) which require independently the same even more generic mixin (BaseMixin). M1 and M2 can be used independently, that means they have to inherit from BaseMixin also independently. But they can be also used in combination. Sometimes M1 and M2 are used in the same component and can mess up the inheritance chain if BaseMixin is applied twice.
In other words, this may happen to the protoype chain ... -> M2 -> BaseMixin -> M1 -> BaseMixin -> ....
An example of this may be a LocalizeMixin used across different components and mixins. Some mixins may need it and many components need it too and can not rely on other mixins to have it by default, so must inherit from it independently.
The more generic the mixin is, the higher the chance of being appliend more than once. As a mixin author you can't control how it is used, and can't always predict it. So as a safety measure it is always recommended to create deduping mixins.
Usage of dedupeMixin()
This is an example of how to make a conventional ES mixin deduping.
const BaseMixin = dedupeMixin((superClass) => {
return class extends superClass { ... };
});
// inherits from BaseMixin
const M1 = dedupeMixin((superClass) => {
return class extends BaseMixin(superClass) { ... };
});
// inherits from BaseMixin
const M2 = dedupeMixin((superClass) => {
return class extends BaseMixin(superClass) { ... };
});
// component inherits from M1
// MyCustomElement -> M1 -> BaseMixin -> BaseCustomElement;
class MyCustomElement extends M1(BaseCustomElement) { ... }
// component inherits from M2
// MyCustomElement -> M2 -> BaseMixin -> BaseCustomElement;
class MyCustomElement extends M2(BaseCustomElement) { ... }
// component inherits from both M1 and M2
// MyCustomElement -> M2 -> M1 -> BaseMixin -> BaseCustomElement;
class MyCustomElement extends M2(M1(BaseCustomElement)) { ... }