Options
All
  • Public
  • Public/Protected
  • All
Menu

External module "lit-html"

Index

Type aliases

DirectiveFn

DirectiveFn: function

Type declaration

    • (part: P): any
    • Parameters

      • part: P

      Returns any

PartCallback

PartCallback: function

Type declaration

TemplateFactory

TemplateFactory: function

A function type that creates a Template from a TemplateResult.

This is a hook into the template-creation process for rendering that requires some modification of templates before their used, like ShadyCSS, which must add classes to elements and remove styles.

Templates should be cached as aggressively as possible, so that many TemplateResults produced from the same expression only do the work of creating the Template the first time.

Templates are usually cached by TemplateResult.strings and TemplateResult.type, but may be cached by other keys if this function modifies the template.

Note that currently TemplateFactories must not add, remove, or reorder expressions, because there is no way to describe such a modification to render() so that values are interpolated to the correct place in the template instances.

Type declaration

Variables

Const directiveValue

directiveValue: object

A sentinel value that signals that a value was handled by a directive and should not be written to the DOM.

Type declaration

Const templateCaches

templateCaches: Map<string, Map<TemplateStringsArray, Template>> = new Map<string, Map<TemplateStringsArray, Template>>()
license

Copyright (c) 2017 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt

Functions

Const defaultPartCallback

defaultTemplateFactory

Const directive

  • directive<P, F>(f: F): F

Const getValue

  • getValue(part: Part, value: any): any
  • Returns a value ready to be inserted into a Part from a user-provided value.

    If the user value is a directive, this invokes the directive with the given part. If the value is null, it's converted to undefined to work better with certain DOM APIs, like textContent.

    Parameters

    • part: Part
    • value: any

    Returns any

Const html

  • html(strings: TemplateStringsArray, ...values: any[]): TemplateResult
  • Interprets a template literal as an HTML template that can efficiently render to and update a container.

    Parameters

    • strings: TemplateStringsArray
    • Rest ...values: any[]

    Returns TemplateResult

Const removeNodes

  • removeNodes(container: Node, startNode: Node | null, endNode?: Node | null): void
  • Removes nodes, starting from startNode (inclusive) to endNode (exclusive), from container.

    Parameters

    • container: Node
    • startNode: Node | null
    • Default value endNode: Node | null = null

    Returns void

render

  • Renders a template to a container.

    To update a container with new values, reevaluate the template literal and call render with the new result.

    Parameters

    • result: TemplateResult

      a TemplateResult created by evaluating a template tag like html or svg.

    • container: Element | DocumentFragment

      A DOM parent to render to. The entire contents are either replaced, or efficiently updated if the same result type was previous rendered there.

    • Default value templateFactory: TemplateFactory = defaultTemplateFactory

      a function to create a Template or retreive one from cache.

    Returns void

Const reparentNodes

  • reparentNodes(container: Node, start: Node | null, end?: Node | null, before?: Node | null): void
  • Reparents nodes, starting from startNode (inclusive) to endNode (exclusive), into another container (could be the same container), before beforeNode. If beforeNode is null, it appends the nodes to the container.

    Parameters

    • container: Node
    • start: Node | null
    • Default value end: Node | null = null
    • Default value before: Node | null = null

    Returns void

Const svg

  • Interprets a template literal as an SVG template that can efficiently render to and update a container.

    Parameters

    • strings: TemplateStringsArray
    • Rest ...values: any[]

    Returns SVGTemplateResult

Generated using TypeDoc