@ktjs/shortcuts
v0.36.2
Published
Shortcut functions for kt.js - common DOM operations
Downloads
200
Readme
KT.js
kt.js is still under development, there might be some breaking api changes.
Recent Updates
- 0.36.x - override 0.35.x. Now refs and computeds have 2 new apis:
get(...keys): create aKTSubComputedobject. It is a light version of computed, used to bind valuessubref(...keys): create aKTSubRefobject. It is a light version of ref, used to bind values and also support two-way binding withk-model.
- 0.34.x -
ref.notify()no-longer has an optional argument. - 0.33.x -
ref.valueremains the standard read API, and it can also replace the whole outer value withref.value = nextValue. - 0.33.x -
ref.draftis the deep-mutation entry for literally any objects. Just usesomeRef.draft.a = someValue, and kt.js will add it to microqueue and redraw it on the next tick. Works forMap,Set,Array,Dateand your custom objects.ref.draftitself is not assignable.
addOnChange((newValue, oldValue) => ...)keepsoldValueas the previous reference, not a deep snapshot.
Community
- QQ Group:
1070434849 - Telegram: https://t.me/kt_js
Introduction
kt.js is a web framework with a tiny runtime that renders real DOM directly (no virtual DOM), uses explicit reactivity variables and gives you manual control over refs, bindings, and redraw timing.
KT.js focuses on one principle: keep direct control of the DOM and avoid unnecessary repainting.
Quick Start
pnpm create kt.js my-app
cd my-app
pnpm install
pnpm devSecurity model
kt.js intentionally trusts application code and keeps DOM operations explicit.
- Text children are inserted as text nodes by default.
k-htmlis a raw HTML escape hatch that writes toinnerHTMLwithout sanitization.- Prefer
on:*event bindings. Do not pass rawonclick/onerrorstyle strings. - Attributes such as
href,src,srcdoc,action, and SVG URL attributes are forwarded as-is. - If you bind untrusted input, sanitization and validation must be handled by your application.
License
MIT License.
