@@ -10,6 +10,13 @@ import {
10
10
} from './mdjsViewerSharedStates.js' ;
11
11
import { addResizeHandler } from './resizeHandler.js' ;
12
12
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
+
13
20
/**
14
21
* @param {string } input
15
22
* @param {'js'|'css' } type
@@ -79,6 +86,16 @@ export class MdJsPreview extends ScopedElementsMixin(LitElement) {
79
86
* TemplateResult, whether the render function of lit 1 or 2 should called.
80
87
* Overriding the render function would look like:
81
88
*
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
+ *
82
99
* @example
83
100
* ```js
84
101
* import { MdJsPreview } from '@mdjs/mdjs-preview';
@@ -87,21 +104,19 @@ export class MdJsPreview extends ScopedElementsMixin(LitElement) {
87
104
* import { render as render1 } from 'lit-html';
88
105
*
89
106
* 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
+ * }
98
113
* }
99
114
* }
100
115
* customElements.define('mdjs-preview', HybridLitMdjsPreview);
101
116
* ```
102
117
*/
103
- get renderFunction ( ) {
104
- return render ;
118
+ renderStory ( html , container , options ) {
119
+ render ( html , container , options ) ;
105
120
}
106
121
107
122
constructor ( ) {
@@ -289,7 +304,10 @@ export class MdJsPreview extends ScopedElementsMixin(LitElement) {
289
304
}
290
305
291
306
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
+ ) ;
293
311
}
294
312
295
313
if ( changeProps . has ( 'platform' ) || changeProps . has ( 'size' ) ) {
0 commit comments