@@ -241,7 +241,8 @@ const COMMENT_PART = 7;
241
241
* The return type of the template tag functions.
242
242
*/
243
243
export type TemplateResult < T extends ResultType = ResultType > = {
244
- _$litType$ : T ;
244
+ // This property needs to remain unminified.
245
+ [ '_$litType$' ] : T ;
245
246
// TODO (justinfagnani): consider shorter names, like `s` and `v`. This is a
246
247
// semi-public API though. We can't just let Terser rename them for us,
247
248
// because we need TemplateResults to work between compatible versions of
@@ -257,7 +258,8 @@ export type SVGTemplateResult = TemplateResult<typeof SVG_RESULT>;
257
258
export interface CompiledTemplateResult {
258
259
// This is a factory in order to make template initialization lazy
259
260
// and allow ShadyRenderOptions scope to be passed in.
260
- _$litType$ : CompiledTemplate ;
261
+ // This property needs to remain unminified.
262
+ [ '_$litType$' ] : CompiledTemplate ;
261
263
values : unknown [ ] ;
262
264
}
263
265
@@ -274,9 +276,10 @@ export interface CompiledTemplate extends Omit<Template, 'el'> {
274
276
* the given result type.
275
277
*/
276
278
const tag =
277
- < T extends ResultType > ( _$litType$ : T ) =>
279
+ < T extends ResultType > ( type : T ) =>
278
280
( strings : TemplateStringsArray , ...values : unknown [ ] ) : TemplateResult < T > => ( {
279
- _$litType$,
281
+ // This property needs to remain unminified.
282
+ [ '_$litType$' ] : type ,
280
283
strings,
281
284
values,
282
285
} ) ;
@@ -355,8 +358,9 @@ export const render = (
355
358
options ?: RenderOptions
356
359
) : ChildPart => {
357
360
const partOwnerNode = options ?. renderBefore ?? container ;
361
+ // This property needs to remain unminified.
358
362
// eslint-disable-next-line @typescript-eslint/no-explicit-any
359
- let part : ChildPart = ( partOwnerNode as any ) . _$litPart$ ;
363
+ let part : ChildPart = ( partOwnerNode as any ) [ ' _$litPart$' ] ;
360
364
if ( part === undefined ) {
361
365
// Internal modification: don't clear container to match lit-html 2.0
362
366
if (
@@ -367,8 +371,9 @@ export const render = (
367
371
container . childNodes . forEach ( ( c ) => c . remove ( ) ) ;
368
372
}
369
373
const endNode = options ?. renderBefore ?? null ;
374
+ // This property needs to remain unminified.
370
375
// eslint-disable-next-line @typescript-eslint/no-explicit-any
371
- ( partOwnerNode as any ) . _$litPart$ = part = new ChildPart (
376
+ ( partOwnerNode as any ) [ ' _$litPart$' ] = part = new ChildPart (
372
377
container . insertBefore ( createMarker ( ) , endNode ) ,
373
378
endNode ,
374
379
undefined ,
@@ -589,7 +594,8 @@ class Template {
589
594
parts : Array < TemplatePart > = [ ] ;
590
595
591
596
constructor (
592
- { strings, _$litType$ : type } : TemplateResult ,
597
+ // This property needs to remain unminified.
598
+ { strings, [ '_$litType$' ] : type } : TemplateResult ,
593
599
options ?: RenderOptions
594
600
) {
595
601
let node : Node | null ;
@@ -749,9 +755,11 @@ function resolveDirective(
749
755
: ( parent as ChildPart | ElementPart | Directive ) . __directive ;
750
756
const nextDirectiveConstructor = isPrimitive ( value )
751
757
? undefined
752
- : ( value as DirectiveResult ) . _$litDirective$ ;
758
+ : // This property needs to remain unminified.
759
+ ( value as DirectiveResult ) [ '_$litDirective$' ] ;
753
760
if ( currentDirective ?. constructor !== nextDirectiveConstructor ) {
754
- currentDirective ?. _$setDirectiveConnected ?.( false ) ;
761
+ // This property needs to remain unminified.
762
+ currentDirective ?. [ '_$setDirectiveConnected' ] ?.( false ) ;
755
763
if ( nextDirectiveConstructor === undefined ) {
756
764
currentDirective = undefined ;
757
765
} else {
@@ -1011,7 +1019,8 @@ class ChildPart {
1011
1019
} else if ( value !== this . _$committedValue && value !== noChange ) {
1012
1020
this . _commitText ( value ) ;
1013
1021
}
1014
- } else if ( ( value as TemplateResult ) . _$litType$ !== undefined ) {
1022
+ // This property needs to remain unminified.
1023
+ } else if ( ( value as TemplateResult ) [ '_$litType$' ] !== undefined ) {
1015
1024
this . _commitTemplateResult ( value as TemplateResult ) ;
1016
1025
} else if ( ( value as Node ) . nodeType !== undefined ) {
1017
1026
this . _commitNode ( value as Node ) ;
@@ -1091,20 +1100,18 @@ class ChildPart {
1091
1100
private _commitTemplateResult (
1092
1101
result : TemplateResult | CompiledTemplateResult
1093
1102
) : void {
1094
- const { values, _$litType$} = result ;
1103
+ // This property needs to remain unminified.
1104
+ const { values, [ '_$litType$' ] : type } = result ;
1095
1105
// If $litType$ is a number, result is a plain TemplateResult and we get
1096
1106
// the template from the template cache. If not, result is a
1097
1107
// CompiledTemplateResult and _$litType$ is a CompiledTemplate and we need
1098
1108
// to create the <template> element the first time we see it.
1099
1109
const template : Template | CompiledTemplate =
1100
- typeof _$litType$ === 'number'
1110
+ typeof type === 'number'
1101
1111
? this . _$getTemplate ( result as TemplateResult )
1102
- : ( _$litType$ . el === undefined &&
1103
- ( _$litType$ . el = Template . createElement (
1104
- _$litType$ . h ,
1105
- this . options
1106
- ) ) ,
1107
- _$litType$ ) ;
1112
+ : ( type . el === undefined &&
1113
+ ( type . el = Template . createElement ( type . h , this . options ) ) ,
1114
+ type ) ;
1108
1115
1109
1116
if ( ( this . _$committedValue as TemplateInstance ) ?. _$template === template ) {
1110
1117
( this . _$committedValue as TemplateInstance ) . _update ( values ) ;
@@ -1233,12 +1240,6 @@ class AttributePart {
1233
1240
_$disconnectableChildren ?: Set < Disconnectable > = undefined ;
1234
1241
1235
1242
protected _sanitizer : ValueSanitizer | undefined ;
1236
- /** @internal */
1237
- _setDirectiveConnected ?: (
1238
- directive : Directive | undefined ,
1239
- isConnected : boolean ,
1240
- removeFromParent ?: boolean
1241
- ) => void = undefined ;
1242
1243
1243
1244
get tagName ( ) {
1244
1245
return this . element . tagName ;
@@ -1489,13 +1490,6 @@ class ElementPart {
1489
1490
/** @internal */
1490
1491
_$disconnectableChildren ?: Set < Disconnectable > = undefined ;
1491
1492
1492
- /** @internal */
1493
- _setDirectiveConnected ?: (
1494
- directive : Directive | undefined ,
1495
- isConnected : boolean ,
1496
- removeFromParent ?: boolean
1497
- ) => void = undefined ;
1498
-
1499
1493
options : RenderOptions | undefined ;
1500
1494
1501
1495
constructor (
0 commit comments