All files / picobel/src/js/wc web-component.ts

100% Statements 11/11
80% Branches 8/10
100% Functions 2/2
100% Lines 11/11

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25        3x   3x       3x 3x 3x 3x 1x 2x   2x       2x 1x    
import { picobel } from "../Picobel";
import { type Options } from "../types";
 
// Create a class for the element
class PicobelWC extends HTMLElement {
    constructor() {
        super();
    }
 
    connectedCallback() {
        const className = this.classList[0] || "default";
        const theme = this.getAttribute("data-theme") || className;
        const options: Options = { theme, context: this };
        const components = this.getAttribute("data-components");
        Iif (components) {
            options.components = JSON.parse(components);
        }
        picobel(options);
    }
}
 
Eif (typeof window !== "undefined" && "customElements" in window) {
    window.customElements.define("picobel-player", PicobelWC);
}