Live editing without replacing controls

The textarea commits its slice on change (leave the field); the text input updates on every input event. Rendering derives new counts from that slice, while DOM merge updates the dependent text without replacing the control being edited.

Word count normalizes whitespace, splits on a space, removes empty fields, and counts the remaining words—including repeated words.

The XPath comparison uses count(tokenize($text)) from a separate text-function library. XPath splits only on XML spaces, tabs, CR and LF; CEM-QL also recognizes Unicode whitespace such as a non-breaking space. Both character counters count Unicode codepoints, including emoji.

See also

XPath regex validation previews

Shared XPath function libraries

Slice declarations and event bindings

CEM-QL string functions