lit-html.d.ts 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621
  1. /**
  2. * @license
  3. * Copyright 2017 Google LLC
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. import type { Directive } from './directive.js';
  7. import type { TrustedHTML } from 'trusted-types/lib/index.js';
  8. /**
  9. * Contains types that are part of the unstable debug API.
  10. *
  11. * Everything in this API is not stable and may change or be removed in the future,
  12. * even on patch releases.
  13. */
  14. export declare namespace LitUnstable {
  15. /**
  16. * When Lit is running in dev mode and `window.emitLitDebugLogEvents` is true,
  17. * we will emit 'lit-debug' events to window, with live details about the update and render
  18. * lifecycle. These can be useful for writing debug tooling and visualizations.
  19. *
  20. * Please be aware that running with window.emitLitDebugLogEvents has performance overhead,
  21. * making certain operations that are normally very cheap (like a no-op render) much slower,
  22. * because we must copy data and dispatch events.
  23. */
  24. namespace DebugLog {
  25. type Entry = TemplatePrep | TemplateInstantiated | TemplateInstantiatedAndUpdated | TemplateUpdating | BeginRender | EndRender | CommitPartEntry | SetPartValue;
  26. interface TemplatePrep {
  27. kind: 'template prep';
  28. template: Template;
  29. strings: TemplateStringsArray;
  30. clonableTemplate: HTMLTemplateElement;
  31. parts: TemplatePart[];
  32. }
  33. interface BeginRender {
  34. kind: 'begin render';
  35. id: number;
  36. value: unknown;
  37. container: RenderRootNode;
  38. options: RenderOptions | undefined;
  39. part: ChildPart | undefined;
  40. }
  41. interface EndRender {
  42. kind: 'end render';
  43. id: number;
  44. value: unknown;
  45. container: RenderRootNode;
  46. options: RenderOptions | undefined;
  47. part: ChildPart;
  48. }
  49. interface TemplateInstantiated {
  50. kind: 'template instantiated';
  51. template: Template | CompiledTemplate;
  52. instance: TemplateInstance;
  53. options: RenderOptions | undefined;
  54. fragment: Node;
  55. parts: Array<Part | undefined>;
  56. values: unknown[];
  57. }
  58. interface TemplateInstantiatedAndUpdated {
  59. kind: 'template instantiated and updated';
  60. template: Template | CompiledTemplate;
  61. instance: TemplateInstance;
  62. options: RenderOptions | undefined;
  63. fragment: Node;
  64. parts: Array<Part | undefined>;
  65. values: unknown[];
  66. }
  67. interface TemplateUpdating {
  68. kind: 'template updating';
  69. template: Template | CompiledTemplate;
  70. instance: TemplateInstance;
  71. options: RenderOptions | undefined;
  72. parts: Array<Part | undefined>;
  73. values: unknown[];
  74. }
  75. interface SetPartValue {
  76. kind: 'set part';
  77. part: Part;
  78. value: unknown;
  79. valueIndex: number;
  80. values: unknown[];
  81. templateInstance: TemplateInstance;
  82. }
  83. type CommitPartEntry = CommitNothingToChildEntry | CommitText | CommitNode | CommitAttribute | CommitProperty | CommitBooleanAttribute | CommitEventListener | CommitToElementBinding;
  84. interface CommitNothingToChildEntry {
  85. kind: 'commit nothing to child';
  86. start: ChildNode;
  87. end: ChildNode | null;
  88. parent: Disconnectable | undefined;
  89. options: RenderOptions | undefined;
  90. }
  91. interface CommitText {
  92. kind: 'commit text';
  93. node: Text;
  94. value: unknown;
  95. options: RenderOptions | undefined;
  96. }
  97. interface CommitNode {
  98. kind: 'commit node';
  99. start: Node;
  100. parent: Disconnectable | undefined;
  101. value: Node;
  102. options: RenderOptions | undefined;
  103. }
  104. interface CommitAttribute {
  105. kind: 'commit attribute';
  106. element: Element;
  107. name: string;
  108. value: unknown;
  109. options: RenderOptions | undefined;
  110. }
  111. interface CommitProperty {
  112. kind: 'commit property';
  113. element: Element;
  114. name: string;
  115. value: unknown;
  116. options: RenderOptions | undefined;
  117. }
  118. interface CommitBooleanAttribute {
  119. kind: 'commit boolean attribute';
  120. element: Element;
  121. name: string;
  122. value: boolean;
  123. options: RenderOptions | undefined;
  124. }
  125. interface CommitEventListener {
  126. kind: 'commit event listener';
  127. element: Element;
  128. name: string;
  129. value: unknown;
  130. oldListener: unknown;
  131. options: RenderOptions | undefined;
  132. removeListener: boolean;
  133. addListener: boolean;
  134. }
  135. interface CommitToElementBinding {
  136. kind: 'commit to element binding';
  137. element: Element;
  138. value: unknown;
  139. options: RenderOptions | undefined;
  140. }
  141. }
  142. }
  143. /**
  144. * Used to sanitize any value before it is written into the DOM. This can be
  145. * used to implement a security policy of allowed and disallowed values in
  146. * order to prevent XSS attacks.
  147. *
  148. * One way of using this callback would be to check attributes and properties
  149. * against a list of high risk fields, and require that values written to such
  150. * fields be instances of a class which is safe by construction. Closure's Safe
  151. * HTML Types is one implementation of this technique (
  152. * https://github.com/google/safe-html-types/blob/master/doc/safehtml-types.md).
  153. * The TrustedTypes polyfill in API-only mode could also be used as a basis
  154. * for this technique (https://github.com/WICG/trusted-types).
  155. *
  156. * @param node The HTML node (usually either a #text node or an Element) that
  157. * is being written to. Note that this is just an exemplar node, the write
  158. * may take place against another instance of the same class of node.
  159. * @param name The name of an attribute or property (for example, 'href').
  160. * @param type Indicates whether the write that's about to be performed will
  161. * be to a property or a node.
  162. * @return A function that will sanitize this class of writes.
  163. */
  164. export type SanitizerFactory = (node: Node, name: string, type: 'property' | 'attribute') => ValueSanitizer;
  165. /**
  166. * A function which can sanitize values that will be written to a specific kind
  167. * of DOM sink.
  168. *
  169. * See SanitizerFactory.
  170. *
  171. * @param value The value to sanitize. Will be the actual value passed into
  172. * the lit-html template literal, so this could be of any type.
  173. * @return The value to write to the DOM. Usually the same as the input value,
  174. * unless sanitization is needed.
  175. */
  176. export type ValueSanitizer = (value: unknown) => unknown;
  177. /** TemplateResult types */
  178. declare const HTML_RESULT = 1;
  179. declare const SVG_RESULT = 2;
  180. declare const MATHML_RESULT = 3;
  181. type ResultType = typeof HTML_RESULT | typeof SVG_RESULT | typeof MATHML_RESULT;
  182. declare const ATTRIBUTE_PART = 1;
  183. declare const CHILD_PART = 2;
  184. declare const PROPERTY_PART = 3;
  185. declare const BOOLEAN_ATTRIBUTE_PART = 4;
  186. declare const EVENT_PART = 5;
  187. declare const ELEMENT_PART = 6;
  188. declare const COMMENT_PART = 7;
  189. /**
  190. * The return type of the template tag functions, {@linkcode html} and
  191. * {@linkcode svg} when it hasn't been compiled by @lit-labs/compiler.
  192. *
  193. * A `TemplateResult` object holds all the information about a template
  194. * expression required to render it: the template strings, expression values,
  195. * and type of template (html or svg).
  196. *
  197. * `TemplateResult` objects do not create any DOM on their own. To create or
  198. * update DOM you need to render the `TemplateResult`. See
  199. * [Rendering](https://lit.dev/docs/components/rendering) for more information.
  200. *
  201. */
  202. export type UncompiledTemplateResult<T extends ResultType = ResultType> = {
  203. ['_$litType$']: T;
  204. strings: TemplateStringsArray;
  205. values: unknown[];
  206. };
  207. /**
  208. * This is a template result that may be either uncompiled or compiled.
  209. *
  210. * In the future, TemplateResult will be this type. If you want to explicitly
  211. * note that a template result is potentially compiled, you can reference this
  212. * type and it will continue to behave the same through the next major version
  213. * of Lit. This can be useful for code that wants to prepare for the next
  214. * major version of Lit.
  215. */
  216. export type MaybeCompiledTemplateResult<T extends ResultType = ResultType> = UncompiledTemplateResult<T> | CompiledTemplateResult;
  217. /**
  218. * The return type of the template tag functions, {@linkcode html} and
  219. * {@linkcode svg}.
  220. *
  221. * A `TemplateResult` object holds all the information about a template
  222. * expression required to render it: the template strings, expression values,
  223. * and type of template (html or svg).
  224. *
  225. * `TemplateResult` objects do not create any DOM on their own. To create or
  226. * update DOM you need to render the `TemplateResult`. See
  227. * [Rendering](https://lit.dev/docs/components/rendering) for more information.
  228. *
  229. * In Lit 4, this type will be an alias of
  230. * MaybeCompiledTemplateResult, so that code will get type errors if it assumes
  231. * that Lit templates are not compiled. When deliberately working with only
  232. * one, use either {@linkcode CompiledTemplateResult} or
  233. * {@linkcode UncompiledTemplateResult} explicitly.
  234. */
  235. export type TemplateResult<T extends ResultType = ResultType> = UncompiledTemplateResult<T>;
  236. export type HTMLTemplateResult = TemplateResult<typeof HTML_RESULT>;
  237. export type SVGTemplateResult = TemplateResult<typeof SVG_RESULT>;
  238. export type MathMLTemplateResult = TemplateResult<typeof MATHML_RESULT>;
  239. /**
  240. * A TemplateResult that has been compiled by @lit-labs/compiler, skipping the
  241. * prepare step.
  242. */
  243. export interface CompiledTemplateResult {
  244. ['_$litType$']: CompiledTemplate;
  245. values: unknown[];
  246. }
  247. export interface CompiledTemplate extends Omit<Template, 'el'> {
  248. el?: HTMLTemplateElement;
  249. h: TemplateStringsArray;
  250. }
  251. /**
  252. * Interprets a template literal as an HTML template that can efficiently
  253. * render to and update a container.
  254. *
  255. * ```ts
  256. * const header = (title: string) => html`<h1>${title}</h1>`;
  257. * ```
  258. *
  259. * The `html` tag returns a description of the DOM to render as a value. It is
  260. * lazy, meaning no work is done until the template is rendered. When rendering,
  261. * if a template comes from the same expression as a previously rendered result,
  262. * it's efficiently updated instead of replaced.
  263. */
  264. export declare const html: (strings: TemplateStringsArray, ...values: unknown[]) => TemplateResult<1>;
  265. /**
  266. * Interprets a template literal as an SVG fragment that can efficiently render
  267. * to and update a container.
  268. *
  269. * ```ts
  270. * const rect = svg`<rect width="10" height="10"></rect>`;
  271. *
  272. * const myImage = html`
  273. * <svg viewBox="0 0 10 10" xmlns="http://www.w3.org/2000/svg">
  274. * ${rect}
  275. * </svg>`;
  276. * ```
  277. *
  278. * The `svg` *tag function* should only be used for SVG fragments, or elements
  279. * that would be contained **inside** an `<svg>` HTML element. A common error is
  280. * placing an `<svg>` *element* in a template tagged with the `svg` tag
  281. * function. The `<svg>` element is an HTML element and should be used within a
  282. * template tagged with the {@linkcode html} tag function.
  283. *
  284. * In LitElement usage, it's invalid to return an SVG fragment from the
  285. * `render()` method, as the SVG fragment will be contained within the element's
  286. * shadow root and thus not be properly contained within an `<svg>` HTML
  287. * element.
  288. */
  289. export declare const svg: (strings: TemplateStringsArray, ...values: unknown[]) => TemplateResult<2>;
  290. /**
  291. * Interprets a template literal as MathML fragment that can efficiently render
  292. * to and update a container.
  293. *
  294. * ```ts
  295. * const num = mathml`<mn>1</mn>`;
  296. *
  297. * const eq = html`
  298. * <math>
  299. * ${num}
  300. * </math>`;
  301. * ```
  302. *
  303. * The `mathml` *tag function* should only be used for MathML fragments, or
  304. * elements that would be contained **inside** a `<math>` HTML element. A common
  305. * error is placing a `<math>` *element* in a template tagged with the `mathml`
  306. * tag function. The `<math>` element is an HTML element and should be used
  307. * within a template tagged with the {@linkcode html} tag function.
  308. *
  309. * In LitElement usage, it's invalid to return an MathML fragment from the
  310. * `render()` method, as the MathML fragment will be contained within the
  311. * element's shadow root and thus not be properly contained within a `<math>`
  312. * HTML element.
  313. */
  314. export declare const mathml: (strings: TemplateStringsArray, ...values: unknown[]) => TemplateResult<3>;
  315. /**
  316. * A sentinel value that signals that a value was handled by a directive and
  317. * should not be written to the DOM.
  318. */
  319. export declare const noChange: unique symbol;
  320. /**
  321. * A sentinel value that signals a ChildPart to fully clear its content.
  322. *
  323. * ```ts
  324. * const button = html`${
  325. * user.isAdmin
  326. * ? html`<button>DELETE</button>`
  327. * : nothing
  328. * }`;
  329. * ```
  330. *
  331. * Prefer using `nothing` over other falsy values as it provides a consistent
  332. * behavior between various expression binding contexts.
  333. *
  334. * In child expressions, `undefined`, `null`, `''`, and `nothing` all behave the
  335. * same and render no nodes. In attribute expressions, `nothing` _removes_ the
  336. * attribute, while `undefined` and `null` will render an empty string. In
  337. * property expressions `nothing` becomes `undefined`.
  338. */
  339. export declare const nothing: unique symbol;
  340. /**
  341. * Object specifying options for controlling lit-html rendering. Note that
  342. * while `render` may be called multiple times on the same `container` (and
  343. * `renderBefore` reference node) to efficiently update the rendered content,
  344. * only the options passed in during the first render are respected during
  345. * the lifetime of renders to that unique `container` + `renderBefore`
  346. * combination.
  347. */
  348. export interface RenderOptions {
  349. /**
  350. * An object to use as the `this` value for event listeners. It's often
  351. * useful to set this to the host component rendering a template.
  352. */
  353. host?: object;
  354. /**
  355. * A DOM node before which to render content in the container.
  356. */
  357. renderBefore?: ChildNode | null;
  358. /**
  359. * Node used for cloning the template (`importNode` will be called on this
  360. * node). This controls the `ownerDocument` of the rendered DOM, along with
  361. * any inherited context. Defaults to the global `document`.
  362. */
  363. creationScope?: {
  364. importNode(node: Node, deep?: boolean): Node;
  365. };
  366. /**
  367. * The initial connected state for the top-level part being rendered. If no
  368. * `isConnected` option is set, `AsyncDirective`s will be connected by
  369. * default. Set to `false` if the initial render occurs in a disconnected tree
  370. * and `AsyncDirective`s should see `isConnected === false` for their initial
  371. * render. The `part.setConnected()` method must be used subsequent to initial
  372. * render to change the connected state of the part.
  373. */
  374. isConnected?: boolean;
  375. }
  376. /**
  377. * The root DOM node for rendering.
  378. */
  379. export type RenderRootNode = HTMLElement | SVGElement | DocumentFragment;
  380. export interface DirectiveParent {
  381. _$parent?: DirectiveParent;
  382. _$isConnected: boolean;
  383. __directive?: Directive;
  384. __directives?: Array<Directive | undefined>;
  385. }
  386. declare class Template {
  387. parts: Array<TemplatePart>;
  388. constructor({ strings, ['_$litType$']: type }: UncompiledTemplateResult, options?: RenderOptions);
  389. /** @nocollapse */
  390. static createElement(html: TrustedHTML, _options?: RenderOptions): HTMLTemplateElement;
  391. }
  392. export interface Disconnectable {
  393. _$parent?: Disconnectable;
  394. _$disconnectableChildren?: Set<Disconnectable>;
  395. _$isConnected: boolean;
  396. }
  397. declare function resolveDirective(part: ChildPart | AttributePart | ElementPart, value: unknown, parent?: DirectiveParent, attributeIndex?: number): unknown;
  398. export type { TemplateInstance };
  399. /**
  400. * An updateable instance of a Template. Holds references to the Parts used to
  401. * update the template instance.
  402. */
  403. declare class TemplateInstance implements Disconnectable {
  404. _$template: Template;
  405. _$parts: Array<Part | undefined>;
  406. constructor(template: Template, parent: ChildPart);
  407. get parentNode(): Node;
  408. get _$isConnected(): boolean;
  409. _clone(options: RenderOptions | undefined): Node;
  410. _update(values: Array<unknown>): void;
  411. }
  412. type AttributeTemplatePart = {
  413. readonly type: typeof ATTRIBUTE_PART;
  414. readonly index: number;
  415. readonly name: string;
  416. readonly ctor: typeof AttributePart;
  417. readonly strings: ReadonlyArray<string>;
  418. };
  419. type ChildTemplatePart = {
  420. readonly type: typeof CHILD_PART;
  421. readonly index: number;
  422. };
  423. type ElementTemplatePart = {
  424. readonly type: typeof ELEMENT_PART;
  425. readonly index: number;
  426. };
  427. type CommentTemplatePart = {
  428. readonly type: typeof COMMENT_PART;
  429. readonly index: number;
  430. };
  431. /**
  432. * A TemplatePart represents a dynamic part in a template, before the template
  433. * is instantiated. When a template is instantiated Parts are created from
  434. * TemplateParts.
  435. */
  436. type TemplatePart = ChildTemplatePart | AttributeTemplatePart | ElementTemplatePart | CommentTemplatePart;
  437. export type Part = ChildPart | AttributePart | PropertyPart | BooleanAttributePart | ElementPart | EventPart;
  438. export type { ChildPart };
  439. declare class ChildPart implements Disconnectable {
  440. readonly type = 2;
  441. readonly options: RenderOptions | undefined;
  442. _$committedValue: unknown;
  443. private _textSanitizer;
  444. get _$isConnected(): boolean;
  445. constructor(startNode: ChildNode, endNode: ChildNode | null, parent: TemplateInstance | ChildPart | undefined, options: RenderOptions | undefined);
  446. /**
  447. * The parent node into which the part renders its content.
  448. *
  449. * A ChildPart's content consists of a range of adjacent child nodes of
  450. * `.parentNode`, possibly bordered by 'marker nodes' (`.startNode` and
  451. * `.endNode`).
  452. *
  453. * - If both `.startNode` and `.endNode` are non-null, then the part's content
  454. * consists of all siblings between `.startNode` and `.endNode`, exclusively.
  455. *
  456. * - If `.startNode` is non-null but `.endNode` is null, then the part's
  457. * content consists of all siblings following `.startNode`, up to and
  458. * including the last child of `.parentNode`. If `.endNode` is non-null, then
  459. * `.startNode` will always be non-null.
  460. *
  461. * - If both `.endNode` and `.startNode` are null, then the part's content
  462. * consists of all child nodes of `.parentNode`.
  463. */
  464. get parentNode(): Node;
  465. /**
  466. * The part's leading marker node, if any. See `.parentNode` for more
  467. * information.
  468. */
  469. get startNode(): Node | null;
  470. /**
  471. * The part's trailing marker node, if any. See `.parentNode` for more
  472. * information.
  473. */
  474. get endNode(): Node | null;
  475. _$setValue(value: unknown, directiveParent?: DirectiveParent): void;
  476. private _insert;
  477. private _commitNode;
  478. private _commitText;
  479. private _commitTemplateResult;
  480. private _commitIterable;
  481. }
  482. /**
  483. * A top-level `ChildPart` returned from `render` that manages the connected
  484. * state of `AsyncDirective`s created throughout the tree below it.
  485. */
  486. export interface RootPart extends ChildPart {
  487. /**
  488. * Sets the connection state for `AsyncDirective`s contained within this root
  489. * ChildPart.
  490. *
  491. * lit-html does not automatically monitor the connectedness of DOM rendered;
  492. * as such, it is the responsibility of the caller to `render` to ensure that
  493. * `part.setConnected(false)` is called before the part object is potentially
  494. * discarded, to ensure that `AsyncDirective`s have a chance to dispose of
  495. * any resources being held. If a `RootPart` that was previously
  496. * disconnected is subsequently re-connected (and its `AsyncDirective`s should
  497. * re-connect), `setConnected(true)` should be called.
  498. *
  499. * @param isConnected Whether directives within this tree should be connected
  500. * or not
  501. */
  502. setConnected(isConnected: boolean): void;
  503. }
  504. export type { AttributePart };
  505. declare class AttributePart implements Disconnectable {
  506. readonly type: typeof ATTRIBUTE_PART | typeof PROPERTY_PART | typeof BOOLEAN_ATTRIBUTE_PART | typeof EVENT_PART;
  507. readonly element: HTMLElement;
  508. readonly name: string;
  509. readonly options: RenderOptions | undefined;
  510. /**
  511. * If this attribute part represents an interpolation, this contains the
  512. * static strings of the interpolation. For single-value, complete bindings,
  513. * this is undefined.
  514. */
  515. readonly strings?: ReadonlyArray<string>;
  516. protected _sanitizer: ValueSanitizer | undefined;
  517. get tagName(): string;
  518. get _$isConnected(): boolean;
  519. constructor(element: HTMLElement, name: string, strings: ReadonlyArray<string>, parent: Disconnectable, options: RenderOptions | undefined);
  520. }
  521. export type { PropertyPart };
  522. declare class PropertyPart extends AttributePart {
  523. readonly type = 3;
  524. }
  525. export type { BooleanAttributePart };
  526. declare class BooleanAttributePart extends AttributePart {
  527. readonly type = 4;
  528. }
  529. /**
  530. * An AttributePart that manages an event listener via add/removeEventListener.
  531. *
  532. * This part works by adding itself as the event listener on an element, then
  533. * delegating to the value passed to it. This reduces the number of calls to
  534. * add/removeEventListener if the listener changes frequently, such as when an
  535. * inline function is used as a listener.
  536. *
  537. * Because event options are passed when adding listeners, we must take case
  538. * to add and remove the part as a listener when the event options change.
  539. */
  540. export type { EventPart };
  541. declare class EventPart extends AttributePart {
  542. readonly type = 5;
  543. constructor(element: HTMLElement, name: string, strings: ReadonlyArray<string>, parent: Disconnectable, options: RenderOptions | undefined);
  544. handleEvent(event: Event): void;
  545. }
  546. export type { ElementPart };
  547. declare class ElementPart implements Disconnectable {
  548. element: Element;
  549. readonly type = 6;
  550. _$committedValue: undefined;
  551. options: RenderOptions | undefined;
  552. constructor(element: Element, parent: Disconnectable, options: RenderOptions | undefined);
  553. get _$isConnected(): boolean;
  554. _$setValue(value: unknown): void;
  555. }
  556. /**
  557. * END USERS SHOULD NOT RELY ON THIS OBJECT.
  558. *
  559. * Private exports for use by other Lit packages, not intended for use by
  560. * external users.
  561. *
  562. * We currently do not make a mangled rollup build of the lit-ssr code. In order
  563. * to keep a number of (otherwise private) top-level exports mangled in the
  564. * client side code, we export a _$LH object containing those members (or
  565. * helper methods for accessing private fields of those members), and then
  566. * re-export them for use in lit-ssr. This keeps lit-ssr agnostic to whether the
  567. * client-side code is being used in `dev` mode or `prod` mode.
  568. *
  569. * This has a unique name, to disambiguate it from private exports in
  570. * lit-element, which re-exports all of lit-html.
  571. *
  572. * @private
  573. */
  574. export declare const _$LH: {
  575. _boundAttributeSuffix: string;
  576. _marker: string;
  577. _markerMatch: string;
  578. _HTML_RESULT: number;
  579. _getTemplateHtml: (strings: TemplateStringsArray, type: ResultType) => [TrustedHTML, Array<string>];
  580. _TemplateInstance: typeof TemplateInstance;
  581. _isIterable: (value: unknown) => value is Iterable<unknown>;
  582. _resolveDirective: typeof resolveDirective;
  583. _ChildPart: typeof ChildPart;
  584. _AttributePart: typeof AttributePart;
  585. _BooleanAttributePart: typeof BooleanAttributePart;
  586. _EventPart: typeof EventPart;
  587. _PropertyPart: typeof PropertyPart;
  588. _ElementPart: typeof ElementPart;
  589. };
  590. /**
  591. * Renders a value, usually a lit-html TemplateResult, to the container.
  592. *
  593. * This example renders the text "Hello, Zoe!" inside a paragraph tag, appending
  594. * it to the container `document.body`.
  595. *
  596. * ```js
  597. * import {html, render} from 'lit';
  598. *
  599. * const name = "Zoe";
  600. * render(html`<p>Hello, ${name}!</p>`, document.body);
  601. * ```
  602. *
  603. * @param value Any [renderable
  604. * value](https://lit.dev/docs/templates/expressions/#child-expressions),
  605. * typically a {@linkcode TemplateResult} created by evaluating a template tag
  606. * like {@linkcode html} or {@linkcode svg}.
  607. * @param container A DOM container to render to. The first render will append
  608. * the rendered value to the container, and subsequent renders will
  609. * efficiently update the rendered value if the same result type was
  610. * previously rendered there.
  611. * @param options See {@linkcode RenderOptions} for options documentation.
  612. * @see
  613. * {@link https://lit.dev/docs/libraries/standalone-templates/#rendering-lit-html-templates| Rendering Lit HTML Templates}
  614. */
  615. export declare const render: {
  616. (value: unknown, container: RenderRootNode, options?: RenderOptions): RootPart;
  617. setSanitizer: (newSanitizer: SanitizerFactory) => void;
  618. createSanitizer: SanitizerFactory;
  619. _testOnlyClearSanitizerFactoryDoNotCallOrElse: () => void;
  620. };
  621. //# sourceMappingURL=lit-html.d.ts.map