@@ -10,6 +10,13 @@ import {
1010} from './mdjsViewerSharedStates.js' ;
1111import { addResizeHandler } from './resizeHandler.js' ;
1212
13+ /**
14+ * @typedef {{values: unknown[], strings:string[],processor:Function} } TemplateResult1
15+ * @typedef {import('lit').TemplateResult } TemplateResult2
16+ * @typedef {{templateFactory:any; eventContext: EventTarget } } RenderOptions1
17+ * @typedef {import('lit').RenderOptions } RenderOptions2
18+ */
19+
1320/**
1421 * @param {string } input
1522 * @param {'js'|'css' } type
@@ -79,6 +86,16 @@ export class MdJsPreview extends ScopedElementsMixin(LitElement) {
7986 * TemplateResult, whether the render function of lit 1 or 2 should called.
8087 * Overriding the render function would look like:
8188 *
89+ * @protected
90+ * @param {TemplateResult1|TemplateResult2|LitHtmlStoryFn } html Any value renderable by NodePart - typically a TemplateResult
91+ * created by evaluating a template tag like `html` or `svg`.
92+ * @param {HTMLElement } container A DOM parent to render to. The entire contents are either
93+ * replaced, or efficiently updated if the same result type was previous
94+ * rendered there.
95+ * @param {Partial<RenderOptions2> } [options] RenderOptions for the entire render tree rendered to this
96+ * container. Render options must *not* change between renders to the same
97+ * container, as those changes will not effect previously rendered DOM.
98+ *
8299 * @example
83100 * ```js
84101 * import { MdJsPreview } from '@mdjs/mdjs-preview';
@@ -87,21 +104,19 @@ export class MdJsPreview extends ScopedElementsMixin(LitElement) {
87104 * import { render as render1 } from 'lit-html';
88105 *
89106 * export class HybridLitMdjsPreview extends MdJsPreview {
90- * get renderFunction() {
91- * return function renderHybrid(html, container, options) {
92- * if (isTemplateResult2(html)) {
93- * render2(html, container, options);
94- * } else {
95- * render1(html, container, options);
96- * }
97- * };
107+ * renderStory(html, container, options) {
108+ * if (isTemplateResult2(html)) {
109+ * render2(html, container, options);
110+ * } else {
111+ * render1(html, container, options);
112+ * }
98113 * }
99114 * }
100115 * customElements.define('mdjs-preview', HybridLitMdjsPreview);
101116 * ```
102117 */
103- get renderFunction ( ) {
104- return render ;
118+ renderStory ( html , container , options ) {
119+ render ( html , container , options ) ;
105120 }
106121
107122 constructor ( ) {
@@ -289,7 +304,10 @@ export class MdJsPreview extends ScopedElementsMixin(LitElement) {
289304 }
290305
291306 if ( this . lightDomRenderTarget && changeProps . has ( 'story' ) ) {
292- this . renderFunction ( this . story ( { shadowRoot : this } ) , this . lightDomRenderTarget ) ;
307+ this . renderStory (
308+ /** @type {LitHtmlStoryFn } */ ( this . story ( { shadowRoot : this } ) ) ,
309+ this . lightDomRenderTarget ,
310+ ) ;
293311 }
294312
295313 if ( changeProps . has ( 'platform' ) || changeProps . has ( 'size' ) ) {
0 commit comments