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 they're 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.
A placeholder for a dynamic expression in an HTML template.
There are two built-in part types: AttributePart and NodePart. NodeParts always represent a single dynamic expression, while AttributeParts may represent as many expressions are contained in the attribute.
A Template's parts are mutable, so parts can be replaced or modified
(possibly to implement different template semantics). The contract is that
parts can only be replaced, not removed, added or reordered, and parts must
always consume the correct number of values in their
TODO(justinfagnani): That requirement is a little fragile. A TemplateInstance could instead be more careful about which values it gives to Part.update().
The first argument to JS template tags retain identity across multiple calls to a tag for the same literal, so we can cache work done per literal in a Map.
Safari currently has a bug which occasionally breaks this behaviour, so we need to cache the Template at two levels. We first cache the TemplateStringsArray, and if that fails, we cache a key constructed by joining the strings array.
Suffix appended to all bound attribute names.
True if the custom elements polyfill is in use.
This regex extracts the attribute name preceding an attribute-position expression. It does this by matching the syntax allowed for attributes against the string literal directly preceding the expression, assuming that the expression is in an attribute-value position.
See attributes in the HTML spec: https://www.w3.org/TR/html5/syntax.html#attributes-0
"\0-\x1F\x7F-\x9F" are Unicode control characters
" \x09\x0a\x0c\x0d" are HTML space characters: https://www.w3.org/TR/html5/infrastructure.html#space-character
So an attribute is:
An expression marker with embedded unique key to avoid collision with possible text in templates.
A sentinel value that signals that a value was handled by a directive and should not be written to the DOM.
An expression marker used text-positions, multi-binding attributes, and attributes with markup-like text values.
Brands a function as a directive so that lit-html will call the function during template rendering, rather than passing as a value.
The directive factory function. Must be a function that returns a
function of the signature
(part: Part) => void. The returned function will
be called with the part object
Interprets a template literal as an HTML template that can efficiently render to and update a container.
Removes nodes, starting from
startNode (inclusive) to
Renders a template to a container.
To update a container with new values, reevaluate the template literal and
render with the new result.
a TemplateResult created by evaluating a template tag like
A DOM parent to render to. The entire contents are either replaced, or efficiently updated if the same result type was previous rendered there.
RenderOptions for the entire render tree rendered to this container. Render options must not change between renders to the same container, as those changes will not effect previously rendered DOM.
Reparents nodes, starting from
startNode (inclusive) to
(exclusive), into another container (could be the same container), before
beforeNode is null, it appends the nodes to the
Interprets a template literal as an SVG template that can efficiently render to and update a container.
Generated using TypeDoc