Icard/angular-clarity-master(work.../node_modules/get-css-data/tests/helpers/inject-test-component.js

33 lines
1.1 KiB
JavaScript
Raw Normal View History

2024-07-16 14:55:36 +00:00
// Export
// =============================================================================
module.exports = function injectTestComponent() {
class TestComponent extends HTMLElement {
constructor() {
super();
this.attachShadow({ mode: 'open' });
}
connectedCallback() {
this.shadowRoot.innerHTML = `
<style data-test-shadow>
.test-component {
background: red;
background: var(--test-component-background, red);
color: white;
}
</style>
<p class="test-component">${this.getAttribute('data-text')}</p>
`;
}
}
window.customElements.define('test-component', TestComponent);
// createElms({ tag: 'style', text: ':root { --test-component-background: green; }', appendTo: 'head' });
// createElms([
// { tag: 'test-component', attr: { 'data-text': 'Custom element' }},
// { tag: 'p', text: 'Standard element' }
// ], { appendTo: 'body' });
};