mirror of
https://github.com/status-im/consul.git
synced 2025-01-19 10:15:06 +00:00
25f3ebd66a
Builds on attach-shadow, adopt-styles and ShadowTemplate, this commit adds ShadowHost and finally CustomElement. CustomElement is a renderless component to help with the creation of native HTML Custom Elements along with runtime type checking and self-documentation for attributes, slots, cssprops and cssparts. As you will probably see there is a little more work to come here. But in the same breath, everything would be fine to go in as is.
22 lines
649 B
JavaScript
22 lines
649 B
JavaScript
import Helper from '@ember/component/helper';
|
|
import { assert } from '@ember/debug';
|
|
import { adoptStyles } from '@lit/reactive-element';
|
|
|
|
export default class AdoptStylesHelper extends Helper {
|
|
/**
|
|
* Adopt/apply given styles to a `ShadowRoot` using constructable styleSheets if supported
|
|
*
|
|
* @param {[ShadowRoot, (CSSResultGroup | CSSResultGroup[])]} params
|
|
*/
|
|
compute([$shadow, styles], hash) {
|
|
assert(
|
|
'adopt-styles can only be used to apply styles to ShadowDOM elements',
|
|
$shadow instanceof ShadowRoot
|
|
);
|
|
if(!Array.isArray(styles)) {
|
|
styles = [styles];
|
|
}
|
|
adoptStyles($shadow, styles);
|
|
}
|
|
}
|