import type { ExplicitSink, HTMLSinkable, Sink } from "../types/sink"; import type { RMLTemplateExpressions, SinkBindingConfiguration } from "../types/internal"; import { SINK_TAG } from "../constants"; import { HTMLString } from "../types"; export const INNER_HTML_SINK_TAG = 'innerHTML'; // consider declarative partial updates // https://developer.chrome.com/blog/declarative-partial-updates export const InnerHTMLSink: Sink = (node: HTMLSinkable) => (html: HTMLString) => { node.innerHTML = html } ; /** * A specialised sink to set the innerHTML of an element * @param source A present or future HTML string * @returns RMLTemplateExpression An HTML-subtree RML template expression * @example
${InnerHTML(stream)}
*/ export const InnerHTML: ExplicitSink<'content'> = (source: RMLTemplateExpressions.HTMLText) => >({ type: SINK_TAG, t: INNER_HTML_SINK_TAG, source, sink: InnerHTMLSink, }) ;