@ktjs/core 0.19.0 → 0.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,6 +8,7 @@ const $throw = (message) => {
8
8
  };
9
9
 
10
10
  // DOM manipulation utilities
11
+ // # dom natives
11
12
  /**
12
13
  * & Remove `bind` because it is shockingly slower than wrapper
13
14
  * & `window.document` is safe because it is not configurable and its setter is undefined
@@ -43,10 +44,11 @@ const $append = // for ie 9/10/11
43
44
  $appendChild.call(this, fragment);
44
45
  }
45
46
  };
47
+ const { get: $buttonDisabledGetter, set: $buttonDisabledSetter } = Object.getOwnPropertyDescriptor(HTMLButtonElement.prototype, 'disabled');
46
48
 
47
49
  // Shared utilities and cached native methods for kt.js framework
48
50
  // Re-export all utilities
49
- Object.defineProperty(window, '@ktjs/shared', { value: '0.19.0' });
51
+ Object.defineProperty(window, '@ktjs/shared', { value: '0.20.0' });
50
52
 
51
53
  const booleanHandler = (element, key, value) => {
52
54
  if (key in element) {
@@ -200,7 +202,7 @@ const svgTempWrapper = document.createElement('div');
200
202
  * ## About
201
203
  * @package @ktjs/core
202
204
  * @author Kasukabe Tsumugi <futami16237@gmail.com>
203
- * @version 0.19.0 (Last Update: 2026.01.31 22:50:55.987)
205
+ * @version 0.20.0 (Last Update: 2026.02.01 00:47:09.995)
204
206
  * @license MIT
205
207
  * @link https://github.com/baendlorel/kt.js
206
208
  * @link https://baendlorel.github.io/ Welcome to my site!
@@ -287,18 +289,10 @@ const dummyRef = { value: null };
287
289
  function jsx(tag, props = {}) {
288
290
  const ref = props.ref?.isKT ? props.ref : dummyRef;
289
291
  let el;
290
- const redraw = (newProps) => {
291
- props = newProps ? { ...props, ...newProps } : props;
292
- el = jsx(tag, props);
293
- if (ref !== dummyRef) {
294
- ref.value = el; // & ref setter automatically replaces old element in DOM
295
- }
296
- return el;
297
- };
298
292
  if ('k-if' in props && !props['k-if']) {
293
+ // & make comment placeholder in case that ref might be redrawn later
299
294
  el = document.createComment('k-if');
300
- ref.value = el; // & ref setter automatically replaces old element in DOM
301
- el.redraw = redraw;
295
+ ref.value = el;
302
296
  return el;
303
297
  }
304
298
  // Handle function components
@@ -308,7 +302,6 @@ function jsx(tag, props = {}) {
308
302
  else {
309
303
  el = h(tag, props, props.children);
310
304
  }
311
- el.redraw ??= redraw;
312
305
  ref.value = el;
313
306
  return el;
314
307
  }
@@ -352,32 +345,6 @@ const jsxDEV = (...args) => {
352
345
  * This is called when using jsx: "react-jsx" or "react-jsxdev"
353
346
  */
354
347
  const jsxs = jsx;
355
- /**
356
- * A helper to create redrawable elements
357
- * ```tsx
358
- * export function MyComponent() {
359
- * let aa = 10;
360
- * // ...
361
- * // aa might be changed
362
- * return createRedrawableNoref(() => <div>{aa}</div>);
363
- * }
364
- * ```
365
- * Then the returned element has a `redraw` method to redraw itself with new values.
366
- * @param creator a simple creator function that returns an element
367
- * @returns created element
368
- */
369
- function createRedrawableNoref(creator) {
370
- let el = creator();
371
- const redraw = () => {
372
- const old = el;
373
- el = creator();
374
- old.replaceWith(el);
375
- el.redraw = redraw;
376
- return el;
377
- };
378
- el.redraw = redraw;
379
- return el;
380
- }
381
348
  /**
382
349
  * A helper to create redrawable elements
383
350
  * ```tsx
@@ -394,14 +361,13 @@ function createRedrawableNoref(creator) {
394
361
  */
395
362
  function createRedrawable(creator) {
396
363
  const elRef = ref();
397
- elRef.value = creator();
398
364
  const redraw = () => {
399
365
  elRef.value = creator(); // ref setter automatically calls replaceWith
400
- elRef.value.redraw = redraw;
366
+ elRef.redraw = redraw;
401
367
  return elRef.value;
402
368
  };
403
- elRef.value.redraw = redraw;
369
+ redraw();
404
370
  return elRef;
405
371
  }
406
372
 
407
- export { Fragment, h as createElement, createRedrawable, createRedrawableNoref, h, jsx, jsxDEV, jsxs };
373
+ export { Fragment, h as createElement, createRedrawable, h, jsx, jsxDEV, jsxs };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ktjs/core",
3
- "version": "0.19.0",
3
+ "version": "0.20.0",
4
4
  "description": "Core functionality for kt.js - DOM manipulation utilities with JSX/TSX support",
5
5
  "type": "module",
6
6
  "module": "./dist/index.mjs",
@@ -44,7 +44,7 @@
44
44
  "directory": "packages/core"
45
45
  },
46
46
  "dependencies": {
47
- "@ktjs/shared": "0.19.0"
47
+ "@ktjs/shared": "0.20.0"
48
48
  },
49
49
  "scripts": {
50
50
  "build": "rollup -c rollup.config.mjs",