Skip to content

Commit

Permalink
docs(src): update jsdocs code
Browse files Browse the repository at this point in the history
  • Loading branch information
waldronmatt committed Apr 8, 2024
1 parent 2da0c9a commit 5f4a816
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import { property } from 'lit/decorators.js';
*
* A shell component for overriding styles and markup.
*
* @fires connected-callback - when `emitConnectedCallback` is `true`
* @fires connected-callback when `emitConnectedCallback` is `true`
* @property {boolean} emitConnectedCallback - Set prop to use `connected-callback` event. Defaults to `false`.
* @param {string} id unique identifier that points to the id of a `template` element. Defaults to empty string.
* @slot `<slot></slot>` fallback rendering behavior if `<template>` element is not found
* @property {string} id - unique identifier that points to the id of a `template` element. Defaults to empty string.
* @slot `<slot></slot>` is rendered as fallback if `<template>` element is not found
*/
export class LitOverride extends EmitConnectedCallback(LitElement) {
@property({ reflect: true, type: String })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ interface AdoptedStyleSheetsConverterParams {
/**
* AdoptedStyleSheetsConverter
*
* A custom controller that detects a `style` tag inside a `template` element from
* the light DOM and then converts and adds it to the component's `adoptedStyleSheets` array.
* Detects a `style` tag inside a `template` element from the light DOM, converts the styles,
* and adds it to the component's `adoptedStyleSheets`.
*
* @param {boolean} clearStyles replace or preserve original styles. Defaults to `false`.
* @param {string} id unique identifier that points to the id of a `template` element. Defaults to empty string.
* @param clearStyles replace or preserve original styles. Defaults to `false`.
* @param id unique identifier that points to the id of a `template` element. Defaults to empty string.
*/
export class AdoptedStyleSheetsConverter implements ReactiveController {
host: ReactiveControllerHost;
Expand Down Expand Up @@ -40,6 +40,10 @@ export class AdoptedStyleSheetsConverter implements ReactiveController {
this.removeComponentStyleTag();
}

private getTemplateElement(): HTMLTemplateElement | null {
return document.querySelector(`template${this.id ? '#' + this.id : ''}`) || document.querySelector('template');
}

private removeComponentStyleTag() {
if (!this._template) {
return;
Expand All @@ -54,10 +58,6 @@ export class AdoptedStyleSheetsConverter implements ReactiveController {
shadowRoot.removeChild(styleElement);
}

private getTemplateElement(): HTMLTemplateElement | null {
return document.querySelector(`template${this.id ? '#' + this.id : ''}`) || document.querySelector('template');
}

private handleAdoptedStyleSheets(styleElement: HTMLStyleElement) {
const litElement = this.host as LitElement;
const shadowRoot = litElement.renderRoot as ShadowRoot;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ class TemplateContentWithFallbackDirective extends Directive {
* Will fallback to your component's markup provided as an argument.
*
*
* @param {TemplateResult} fallback renders markup if a `template` element is not found. Defaults to `<slot></slot>`.
* @param {string} id unique identifier that points to the id of a `template` element. Defaults to empty string.
* @param fallback renders markup if a `template` element is not found. Defaults to `<slot></slot>`.
* @param id unique identifier that points to the id of a `template` element. Defaults to empty string.
*/
// @ts-expect-error - ignore typing error
export const templateContentWithFallback = directive(TemplateContentWithFallbackDirective);
Expand Down
3 changes: 1 addition & 2 deletions packages/lit-override/src/mixins/emit-connected-callback.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ export declare class EmitConnectedCallbackInterface {
/**
* LitOverrideMixin
*
* A mixin that enables your component to emit `connected-callback` if
* `emitConnectedCallback` prop is set.
* Enables your component to emit `connected-callback` if `emitConnectedCallback` prop is set.
*
* @fires connected-callback when `emitConnectedCallback` is `true`
* @property {boolean} emitConnectedCallback - Set prop to use `connected-callback` event. Defaults to `false`.
Expand Down
3 changes: 0 additions & 3 deletions packages/lit-override/src/utils/markup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ import { LitElement, TemplateResult } from 'lit';
*
* **Note**: Only static markdown is supported.
*
* **Note**: This utility clears DOM nodes which can cause performance bottlenecks if there are a lot
* of components and/or existing DOM elements. Use cautiously.
*
*/
export const injectTemplate = (elements: NodeListOf<Element> | Array<Element>, template: TemplateResult): void => {
if (!elements || !elements.length || !template) {
Expand Down

0 comments on commit 5f4a816

Please sign in to comment.