Home > @polyspec/crudui-generator-core > patchContent
patchContent() function
Replace an element's content with rendered markup while keeping every existing node that the new markup still contains. A string renderer re-renders the whole form after each change; patching keeps the focused control, its text selection and an input method composition, as the framework renderers do.
Nodes match by kind and element name, and elements by their identity: a row key, a field path, an id, or a control name with its value for checkboxes and radio buttons. Unkeyed nodes match in order. Attributes are set to those of the new markup; control values and checked states are live properties, which connectForm().sync() sets from the form.
A script runs once, when its markup first appears: each script in inserted markup becomes a new script element once the whole markup is in place, and the browser runs it when it is connected, so a script finds the controls that follow it. A kept script never runs again: a parsed or cloned script never runs, and changing a started script's text does not run it.
Signature:
export declare function patchContent(element: Element, html: string): void;
Parameters
|
Parameter |
Type |
Description |
|---|---|---|
|
element |
Element | |
|
html |
string |
Returns:
void