@ktjs/core 0.22.5 → 0.23.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.
- package/dist/index.d.ts +7 -1
- package/dist/index.iife.js +31 -5
- package/dist/index.legacy.js +31 -5
- package/dist/index.mjs +31 -5
- package/dist/jsx/index.d.ts +7 -1
- package/dist/jsx/index.mjs +31 -5
- package/dist/jsx/jsx-runtime.d.ts +7 -1
- package/dist/jsx/jsx-runtime.mjs +31 -5
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -95,6 +95,12 @@ interface KTBaseAttribute {
|
|
|
95
95
|
*/
|
|
96
96
|
'k-model'?: KTRef<any>;
|
|
97
97
|
|
|
98
|
+
/**
|
|
99
|
+
* Directly apply html string to `innerHTML`.
|
|
100
|
+
* - Would be reactive if `KTRef` instance is provided
|
|
101
|
+
*/
|
|
102
|
+
'k-html'?: any;
|
|
103
|
+
|
|
98
104
|
// # normal HTML attributes
|
|
99
105
|
id?: string;
|
|
100
106
|
class?: string;
|
|
@@ -172,7 +178,7 @@ type KTComponent = (
|
|
|
172
178
|
* ## About
|
|
173
179
|
* @package @ktjs/core
|
|
174
180
|
* @author Kasukabe Tsumugi <futami16237@gmail.com>
|
|
175
|
-
* @version 0.
|
|
181
|
+
* @version 0.23.0 (Last Update: 2026.02.03 17:15:01.812)
|
|
176
182
|
* @license MIT
|
|
177
183
|
* @link https://github.com/baendlorel/kt.js
|
|
178
184
|
* @link https://baendlorel.github.io/ Welcome to my site!
|
package/dist/index.iife.js
CHANGED
|
@@ -8,6 +8,7 @@ var __ktjs_core__ = (function (exports) {
|
|
|
8
8
|
|
|
9
9
|
// DOM manipulation utilities
|
|
10
10
|
// # dom natives
|
|
11
|
+
const $isNode = (x) => x?.nodeType > 0;
|
|
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
|
|
@@ -54,8 +55,9 @@ var __ktjs_core__ = (function (exports) {
|
|
|
54
55
|
};
|
|
55
56
|
|
|
56
57
|
// Shared utilities and cached native methods for kt.js framework
|
|
58
|
+
// import './misc/symbol-polyfill.js';
|
|
57
59
|
// Re-export all utilities
|
|
58
|
-
Object.defineProperty(window, '__ktjs__', { value: '0.22.
|
|
60
|
+
Object.defineProperty(window, '__ktjs__', { value: '0.22.3' });
|
|
59
61
|
|
|
60
62
|
class KTRef {
|
|
61
63
|
/**
|
|
@@ -235,13 +237,24 @@ var __ktjs_core__ = (function (exports) {
|
|
|
235
237
|
}
|
|
236
238
|
}
|
|
237
239
|
}
|
|
240
|
+
if ('k-html' in attr) {
|
|
241
|
+
const html = attr['k-html'];
|
|
242
|
+
if (isKTRef(html)) {
|
|
243
|
+
element.innerHTML = html.value;
|
|
244
|
+
html.addOnChange((v) => (element.innerHTML = v));
|
|
245
|
+
}
|
|
246
|
+
else {
|
|
247
|
+
element.innerHTML = html;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
238
250
|
for (const key in attr) {
|
|
239
251
|
if (key === 'class' ||
|
|
240
252
|
key === 'className' ||
|
|
241
253
|
key === 'style' ||
|
|
242
254
|
key === 'children' ||
|
|
243
255
|
key === 'k-if' ||
|
|
244
|
-
key
|
|
256
|
+
key === 'k-model' ||
|
|
257
|
+
key === 'k-html' ||
|
|
245
258
|
key === 'ref') {
|
|
246
259
|
continue;
|
|
247
260
|
}
|
|
@@ -252,6 +265,7 @@ var __ktjs_core__ = (function (exports) {
|
|
|
252
265
|
}
|
|
253
266
|
// normal attributes
|
|
254
267
|
else {
|
|
268
|
+
// todo 这里也可以绑定ref的
|
|
255
269
|
(handlers[key] || defaultHandler)(element, key, o);
|
|
256
270
|
}
|
|
257
271
|
}
|
|
@@ -268,13 +282,25 @@ var __ktjs_core__ = (function (exports) {
|
|
|
268
282
|
}
|
|
269
283
|
}
|
|
270
284
|
|
|
285
|
+
const assureNode = (o) => ($isNode(o) ? o : document.createTextNode(o));
|
|
271
286
|
function apdSingle(element, c) {
|
|
272
287
|
// & JSX should ignore false, undefined, and null
|
|
273
288
|
if (c === false || c === undefined || c === null) {
|
|
274
289
|
return;
|
|
275
290
|
}
|
|
276
|
-
if (
|
|
277
|
-
|
|
291
|
+
if (isKTRef(c)) {
|
|
292
|
+
let node = assureNode(c.value);
|
|
293
|
+
$append.call(element, node);
|
|
294
|
+
c.addOnChange((newValue, oldValue) => {
|
|
295
|
+
if ($isNode(newValue) && $isNode(oldValue)) {
|
|
296
|
+
// & this case is handled automically in `class KTRef`
|
|
297
|
+
// todo 2 cases might be able to merge into 1
|
|
298
|
+
return;
|
|
299
|
+
}
|
|
300
|
+
const oldNode = node;
|
|
301
|
+
node = assureNode(newValue);
|
|
302
|
+
oldNode.replaceWith(node);
|
|
303
|
+
});
|
|
278
304
|
}
|
|
279
305
|
else {
|
|
280
306
|
$append.call(element, c);
|
|
@@ -360,7 +386,7 @@ var __ktjs_core__ = (function (exports) {
|
|
|
360
386
|
* ## About
|
|
361
387
|
* @package @ktjs/core
|
|
362
388
|
* @author Kasukabe Tsumugi <futami16237@gmail.com>
|
|
363
|
-
* @version 0.
|
|
389
|
+
* @version 0.23.0 (Last Update: 2026.02.03 17:15:01.812)
|
|
364
390
|
* @license MIT
|
|
365
391
|
* @link https://github.com/baendlorel/kt.js
|
|
366
392
|
* @link https://baendlorel.github.io/ Welcome to my site!
|
package/dist/index.legacy.js
CHANGED
|
@@ -8,6 +8,7 @@ var __ktjs_core__ = (function (exports) {
|
|
|
8
8
|
|
|
9
9
|
// DOM manipulation utilities
|
|
10
10
|
// # dom natives
|
|
11
|
+
const $isNode = (x) => x?.nodeType > 0;
|
|
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
|
|
@@ -54,8 +55,9 @@ var __ktjs_core__ = (function (exports) {
|
|
|
54
55
|
};
|
|
55
56
|
|
|
56
57
|
// Shared utilities and cached native methods for kt.js framework
|
|
58
|
+
// import './misc/symbol-polyfill.js';
|
|
57
59
|
// Re-export all utilities
|
|
58
|
-
Object.defineProperty(window, '__ktjs__', { value: '0.22.
|
|
60
|
+
Object.defineProperty(window, '__ktjs__', { value: '0.22.3' });
|
|
59
61
|
|
|
60
62
|
var KTRef = /** @class */ (function () {
|
|
61
63
|
function KTRef(_value, _onChanges) {
|
|
@@ -234,13 +236,24 @@ var __ktjs_core__ = (function (exports) {
|
|
|
234
236
|
}
|
|
235
237
|
}
|
|
236
238
|
}
|
|
239
|
+
if ('k-html' in attr) {
|
|
240
|
+
var html = attr['k-html'];
|
|
241
|
+
if (isKTRef(html)) {
|
|
242
|
+
element.innerHTML = html.value;
|
|
243
|
+
html.addOnChange(function (v) { return (element.innerHTML = v); });
|
|
244
|
+
}
|
|
245
|
+
else {
|
|
246
|
+
element.innerHTML = html;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
237
249
|
for (var key in attr) {
|
|
238
250
|
if (key === 'class' ||
|
|
239
251
|
key === 'className' ||
|
|
240
252
|
key === 'style' ||
|
|
241
253
|
key === 'children' ||
|
|
242
254
|
key === 'k-if' ||
|
|
243
|
-
key
|
|
255
|
+
key === 'k-model' ||
|
|
256
|
+
key === 'k-html' ||
|
|
244
257
|
key === 'ref') {
|
|
245
258
|
continue;
|
|
246
259
|
}
|
|
@@ -251,6 +264,7 @@ var __ktjs_core__ = (function (exports) {
|
|
|
251
264
|
}
|
|
252
265
|
// normal attributes
|
|
253
266
|
else {
|
|
267
|
+
// todo 这里也可以绑定ref的
|
|
254
268
|
(handlers[key] || defaultHandler)(element, key, o);
|
|
255
269
|
}
|
|
256
270
|
}
|
|
@@ -267,13 +281,25 @@ var __ktjs_core__ = (function (exports) {
|
|
|
267
281
|
}
|
|
268
282
|
}
|
|
269
283
|
|
|
284
|
+
var assureNode = function (o) { return ($isNode(o) ? o : document.createTextNode(o)); };
|
|
270
285
|
function apdSingle(element, c) {
|
|
271
286
|
// & JSX should ignore false, undefined, and null
|
|
272
287
|
if (c === false || c === undefined || c === null) {
|
|
273
288
|
return;
|
|
274
289
|
}
|
|
275
|
-
if (
|
|
276
|
-
|
|
290
|
+
if (isKTRef(c)) {
|
|
291
|
+
var node_1 = assureNode(c.value);
|
|
292
|
+
$append.call(element, node_1);
|
|
293
|
+
c.addOnChange(function (newValue, oldValue) {
|
|
294
|
+
if ($isNode(newValue) && $isNode(oldValue)) {
|
|
295
|
+
// & this case is handled automically in `class KTRef`
|
|
296
|
+
// todo 2 cases might be able to merge into 1
|
|
297
|
+
return;
|
|
298
|
+
}
|
|
299
|
+
var oldNode = node_1;
|
|
300
|
+
node_1 = assureNode(newValue);
|
|
301
|
+
oldNode.replaceWith(node_1);
|
|
302
|
+
});
|
|
277
303
|
}
|
|
278
304
|
else {
|
|
279
305
|
$append.call(element, c);
|
|
@@ -362,7 +388,7 @@ var __ktjs_core__ = (function (exports) {
|
|
|
362
388
|
* ## About
|
|
363
389
|
* @package @ktjs/core
|
|
364
390
|
* @author Kasukabe Tsumugi <futami16237@gmail.com>
|
|
365
|
-
* @version 0.
|
|
391
|
+
* @version 0.23.0 (Last Update: 2026.02.03 17:15:01.812)
|
|
366
392
|
* @license MIT
|
|
367
393
|
* @link https://github.com/baendlorel/kt.js
|
|
368
394
|
* @link https://baendlorel.github.io/ Welcome to my site!
|
package/dist/index.mjs
CHANGED
|
@@ -5,6 +5,7 @@ const $isThenable = (o) => typeof o === 'object' && o !== null && typeof o.then
|
|
|
5
5
|
|
|
6
6
|
// DOM manipulation utilities
|
|
7
7
|
// # dom natives
|
|
8
|
+
const $isNode = (x) => x?.nodeType > 0;
|
|
8
9
|
/**
|
|
9
10
|
* & Remove `bind` because it is shockingly slower than wrapper
|
|
10
11
|
* & `window.document` is safe because it is not configurable and its setter is undefined
|
|
@@ -51,8 +52,9 @@ const applyModel = (element, valueRef, propName, eventName) => {
|
|
|
51
52
|
};
|
|
52
53
|
|
|
53
54
|
// Shared utilities and cached native methods for kt.js framework
|
|
55
|
+
// import './misc/symbol-polyfill.js';
|
|
54
56
|
// Re-export all utilities
|
|
55
|
-
Object.defineProperty(window, '__ktjs__', { value: '0.22.
|
|
57
|
+
Object.defineProperty(window, '__ktjs__', { value: '0.22.3' });
|
|
56
58
|
|
|
57
59
|
class KTRef {
|
|
58
60
|
/**
|
|
@@ -232,13 +234,24 @@ function attrIsObject(element, attr) {
|
|
|
232
234
|
}
|
|
233
235
|
}
|
|
234
236
|
}
|
|
237
|
+
if ('k-html' in attr) {
|
|
238
|
+
const html = attr['k-html'];
|
|
239
|
+
if (isKTRef(html)) {
|
|
240
|
+
element.innerHTML = html.value;
|
|
241
|
+
html.addOnChange((v) => (element.innerHTML = v));
|
|
242
|
+
}
|
|
243
|
+
else {
|
|
244
|
+
element.innerHTML = html;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
235
247
|
for (const key in attr) {
|
|
236
248
|
if (key === 'class' ||
|
|
237
249
|
key === 'className' ||
|
|
238
250
|
key === 'style' ||
|
|
239
251
|
key === 'children' ||
|
|
240
252
|
key === 'k-if' ||
|
|
241
|
-
key
|
|
253
|
+
key === 'k-model' ||
|
|
254
|
+
key === 'k-html' ||
|
|
242
255
|
key === 'ref') {
|
|
243
256
|
continue;
|
|
244
257
|
}
|
|
@@ -249,6 +262,7 @@ function attrIsObject(element, attr) {
|
|
|
249
262
|
}
|
|
250
263
|
// normal attributes
|
|
251
264
|
else {
|
|
265
|
+
// todo 这里也可以绑定ref的
|
|
252
266
|
(handlers[key] || defaultHandler)(element, key, o);
|
|
253
267
|
}
|
|
254
268
|
}
|
|
@@ -265,13 +279,25 @@ function applyAttr(element, attr) {
|
|
|
265
279
|
}
|
|
266
280
|
}
|
|
267
281
|
|
|
282
|
+
const assureNode = (o) => ($isNode(o) ? o : document.createTextNode(o));
|
|
268
283
|
function apdSingle(element, c) {
|
|
269
284
|
// & JSX should ignore false, undefined, and null
|
|
270
285
|
if (c === false || c === undefined || c === null) {
|
|
271
286
|
return;
|
|
272
287
|
}
|
|
273
|
-
if (
|
|
274
|
-
|
|
288
|
+
if (isKTRef(c)) {
|
|
289
|
+
let node = assureNode(c.value);
|
|
290
|
+
$append.call(element, node);
|
|
291
|
+
c.addOnChange((newValue, oldValue) => {
|
|
292
|
+
if ($isNode(newValue) && $isNode(oldValue)) {
|
|
293
|
+
// & this case is handled automically in `class KTRef`
|
|
294
|
+
// todo 2 cases might be able to merge into 1
|
|
295
|
+
return;
|
|
296
|
+
}
|
|
297
|
+
const oldNode = node;
|
|
298
|
+
node = assureNode(newValue);
|
|
299
|
+
oldNode.replaceWith(node);
|
|
300
|
+
});
|
|
275
301
|
}
|
|
276
302
|
else {
|
|
277
303
|
$append.call(element, c);
|
|
@@ -357,7 +383,7 @@ const MATHML_ATTR_FLAG = '__kt_mathml__';
|
|
|
357
383
|
* ## About
|
|
358
384
|
* @package @ktjs/core
|
|
359
385
|
* @author Kasukabe Tsumugi <futami16237@gmail.com>
|
|
360
|
-
* @version 0.
|
|
386
|
+
* @version 0.23.0 (Last Update: 2026.02.03 17:15:01.812)
|
|
361
387
|
* @license MIT
|
|
362
388
|
* @link https://github.com/baendlorel/kt.js
|
|
363
389
|
* @link https://baendlorel.github.io/ Welcome to my site!
|
package/dist/jsx/index.d.ts
CHANGED
|
@@ -87,6 +87,12 @@ interface KTBaseAttribute {
|
|
|
87
87
|
*/
|
|
88
88
|
'k-model'?: KTRef<any>;
|
|
89
89
|
|
|
90
|
+
/**
|
|
91
|
+
* Directly apply html string to `innerHTML`.
|
|
92
|
+
* - Would be reactive if `KTRef` instance is provided
|
|
93
|
+
*/
|
|
94
|
+
'k-html'?: any;
|
|
95
|
+
|
|
90
96
|
// # normal HTML attributes
|
|
91
97
|
id?: string;
|
|
92
98
|
class?: string;
|
|
@@ -156,7 +162,7 @@ type KTAttribute = KTBaseAttribute & KTPrefixedEventHandlers;
|
|
|
156
162
|
* ## About
|
|
157
163
|
* @package @ktjs/core
|
|
158
164
|
* @author Kasukabe Tsumugi <futami16237@gmail.com>
|
|
159
|
-
* @version 0.
|
|
165
|
+
* @version 0.23.0 (Last Update: 2026.02.03 17:15:01.812)
|
|
160
166
|
* @license MIT
|
|
161
167
|
* @link https://github.com/baendlorel/kt.js
|
|
162
168
|
* @link https://baendlorel.github.io/ Welcome to my site!
|
package/dist/jsx/index.mjs
CHANGED
|
@@ -5,6 +5,7 @@ const $isThenable = (o) => typeof o === 'object' && o !== null && typeof o.then
|
|
|
5
5
|
|
|
6
6
|
// DOM manipulation utilities
|
|
7
7
|
// # dom natives
|
|
8
|
+
const $isNode = (x) => x?.nodeType > 0;
|
|
8
9
|
/**
|
|
9
10
|
* & Remove `bind` because it is shockingly slower than wrapper
|
|
10
11
|
* & `window.document` is safe because it is not configurable and its setter is undefined
|
|
@@ -51,8 +52,9 @@ const applyModel = (element, valueRef, propName, eventName) => {
|
|
|
51
52
|
};
|
|
52
53
|
|
|
53
54
|
// Shared utilities and cached native methods for kt.js framework
|
|
55
|
+
// import './misc/symbol-polyfill.js';
|
|
54
56
|
// Re-export all utilities
|
|
55
|
-
Object.defineProperty(window, '__ktjs__', { value: '0.22.
|
|
57
|
+
Object.defineProperty(window, '__ktjs__', { value: '0.22.3' });
|
|
56
58
|
|
|
57
59
|
class KTRef {
|
|
58
60
|
/**
|
|
@@ -232,13 +234,24 @@ function attrIsObject(element, attr) {
|
|
|
232
234
|
}
|
|
233
235
|
}
|
|
234
236
|
}
|
|
237
|
+
if ('k-html' in attr) {
|
|
238
|
+
const html = attr['k-html'];
|
|
239
|
+
if (isKTRef(html)) {
|
|
240
|
+
element.innerHTML = html.value;
|
|
241
|
+
html.addOnChange((v) => (element.innerHTML = v));
|
|
242
|
+
}
|
|
243
|
+
else {
|
|
244
|
+
element.innerHTML = html;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
235
247
|
for (const key in attr) {
|
|
236
248
|
if (key === 'class' ||
|
|
237
249
|
key === 'className' ||
|
|
238
250
|
key === 'style' ||
|
|
239
251
|
key === 'children' ||
|
|
240
252
|
key === 'k-if' ||
|
|
241
|
-
key
|
|
253
|
+
key === 'k-model' ||
|
|
254
|
+
key === 'k-html' ||
|
|
242
255
|
key === 'ref') {
|
|
243
256
|
continue;
|
|
244
257
|
}
|
|
@@ -249,6 +262,7 @@ function attrIsObject(element, attr) {
|
|
|
249
262
|
}
|
|
250
263
|
// normal attributes
|
|
251
264
|
else {
|
|
265
|
+
// todo 这里也可以绑定ref的
|
|
252
266
|
(handlers[key] || defaultHandler)(element, key, o);
|
|
253
267
|
}
|
|
254
268
|
}
|
|
@@ -265,13 +279,25 @@ function applyAttr(element, attr) {
|
|
|
265
279
|
}
|
|
266
280
|
}
|
|
267
281
|
|
|
282
|
+
const assureNode = (o) => ($isNode(o) ? o : document.createTextNode(o));
|
|
268
283
|
function apdSingle(element, c) {
|
|
269
284
|
// & JSX should ignore false, undefined, and null
|
|
270
285
|
if (c === false || c === undefined || c === null) {
|
|
271
286
|
return;
|
|
272
287
|
}
|
|
273
|
-
if (
|
|
274
|
-
|
|
288
|
+
if (isKTRef(c)) {
|
|
289
|
+
let node = assureNode(c.value);
|
|
290
|
+
$append.call(element, node);
|
|
291
|
+
c.addOnChange((newValue, oldValue) => {
|
|
292
|
+
if ($isNode(newValue) && $isNode(oldValue)) {
|
|
293
|
+
// & this case is handled automically in `class KTRef`
|
|
294
|
+
// todo 2 cases might be able to merge into 1
|
|
295
|
+
return;
|
|
296
|
+
}
|
|
297
|
+
const oldNode = node;
|
|
298
|
+
node = assureNode(newValue);
|
|
299
|
+
oldNode.replaceWith(node);
|
|
300
|
+
});
|
|
275
301
|
}
|
|
276
302
|
else {
|
|
277
303
|
$append.call(element, c);
|
|
@@ -357,7 +383,7 @@ const MATHML_ATTR_FLAG = '__kt_mathml__';
|
|
|
357
383
|
* ## About
|
|
358
384
|
* @package @ktjs/core
|
|
359
385
|
* @author Kasukabe Tsumugi <futami16237@gmail.com>
|
|
360
|
-
* @version 0.
|
|
386
|
+
* @version 0.23.0 (Last Update: 2026.02.03 17:15:01.812)
|
|
361
387
|
* @license MIT
|
|
362
388
|
* @link https://github.com/baendlorel/kt.js
|
|
363
389
|
* @link https://baendlorel.github.io/ Welcome to my site!
|
|
@@ -60,6 +60,12 @@ interface KTBaseAttribute {
|
|
|
60
60
|
*/
|
|
61
61
|
'k-model'?: KTRef<any>;
|
|
62
62
|
|
|
63
|
+
/**
|
|
64
|
+
* Directly apply html string to `innerHTML`.
|
|
65
|
+
* - Would be reactive if `KTRef` instance is provided
|
|
66
|
+
*/
|
|
67
|
+
'k-html'?: any;
|
|
68
|
+
|
|
63
69
|
// # normal HTML attributes
|
|
64
70
|
id?: string;
|
|
65
71
|
class?: string;
|
|
@@ -129,7 +135,7 @@ type KTAttribute = KTBaseAttribute & KTPrefixedEventHandlers;
|
|
|
129
135
|
* ## About
|
|
130
136
|
* @package @ktjs/core
|
|
131
137
|
* @author Kasukabe Tsumugi <futami16237@gmail.com>
|
|
132
|
-
* @version 0.
|
|
138
|
+
* @version 0.23.0 (Last Update: 2026.02.03 17:15:01.812)
|
|
133
139
|
* @license MIT
|
|
134
140
|
* @link https://github.com/baendlorel/kt.js
|
|
135
141
|
* @link https://baendlorel.github.io/ Welcome to my site!
|
package/dist/jsx/jsx-runtime.mjs
CHANGED
|
@@ -4,6 +4,7 @@ const $isThenable = (o) => typeof o === 'object' && o !== null && typeof o.then
|
|
|
4
4
|
|
|
5
5
|
// DOM manipulation utilities
|
|
6
6
|
// # dom natives
|
|
7
|
+
const $isNode = (x) => x?.nodeType > 0;
|
|
7
8
|
/**
|
|
8
9
|
* & Remove `bind` because it is shockingly slower than wrapper
|
|
9
10
|
* & `window.document` is safe because it is not configurable and its setter is undefined
|
|
@@ -50,8 +51,9 @@ const applyModel = (element, valueRef, propName, eventName) => {
|
|
|
50
51
|
};
|
|
51
52
|
|
|
52
53
|
// Shared utilities and cached native methods for kt.js framework
|
|
54
|
+
// import './misc/symbol-polyfill.js';
|
|
53
55
|
// Re-export all utilities
|
|
54
|
-
Object.defineProperty(window, '__ktjs__', { value: '0.22.
|
|
56
|
+
Object.defineProperty(window, '__ktjs__', { value: '0.22.3' });
|
|
55
57
|
|
|
56
58
|
class KTRef {
|
|
57
59
|
/**
|
|
@@ -186,13 +188,24 @@ function attrIsObject(element, attr) {
|
|
|
186
188
|
}
|
|
187
189
|
}
|
|
188
190
|
}
|
|
191
|
+
if ('k-html' in attr) {
|
|
192
|
+
const html = attr['k-html'];
|
|
193
|
+
if (isKTRef(html)) {
|
|
194
|
+
element.innerHTML = html.value;
|
|
195
|
+
html.addOnChange((v) => (element.innerHTML = v));
|
|
196
|
+
}
|
|
197
|
+
else {
|
|
198
|
+
element.innerHTML = html;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
189
201
|
for (const key in attr) {
|
|
190
202
|
if (key === 'class' ||
|
|
191
203
|
key === 'className' ||
|
|
192
204
|
key === 'style' ||
|
|
193
205
|
key === 'children' ||
|
|
194
206
|
key === 'k-if' ||
|
|
195
|
-
key
|
|
207
|
+
key === 'k-model' ||
|
|
208
|
+
key === 'k-html' ||
|
|
196
209
|
key === 'ref') {
|
|
197
210
|
continue;
|
|
198
211
|
}
|
|
@@ -203,6 +216,7 @@ function attrIsObject(element, attr) {
|
|
|
203
216
|
}
|
|
204
217
|
// normal attributes
|
|
205
218
|
else {
|
|
219
|
+
// todo 这里也可以绑定ref的
|
|
206
220
|
(handlers[key] || defaultHandler)(element, key, o);
|
|
207
221
|
}
|
|
208
222
|
}
|
|
@@ -219,13 +233,25 @@ function applyAttr(element, attr) {
|
|
|
219
233
|
}
|
|
220
234
|
}
|
|
221
235
|
|
|
236
|
+
const assureNode = (o) => ($isNode(o) ? o : document.createTextNode(o));
|
|
222
237
|
function apdSingle(element, c) {
|
|
223
238
|
// & JSX should ignore false, undefined, and null
|
|
224
239
|
if (c === false || c === undefined || c === null) {
|
|
225
240
|
return;
|
|
226
241
|
}
|
|
227
|
-
if (
|
|
228
|
-
|
|
242
|
+
if (isKTRef(c)) {
|
|
243
|
+
let node = assureNode(c.value);
|
|
244
|
+
$append.call(element, node);
|
|
245
|
+
c.addOnChange((newValue, oldValue) => {
|
|
246
|
+
if ($isNode(newValue) && $isNode(oldValue)) {
|
|
247
|
+
// & this case is handled automically in `class KTRef`
|
|
248
|
+
// todo 2 cases might be able to merge into 1
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
const oldNode = node;
|
|
252
|
+
node = assureNode(newValue);
|
|
253
|
+
oldNode.replaceWith(node);
|
|
254
|
+
});
|
|
229
255
|
}
|
|
230
256
|
else {
|
|
231
257
|
$append.call(element, c);
|
|
@@ -311,7 +337,7 @@ const MATHML_ATTR_FLAG = '__kt_mathml__';
|
|
|
311
337
|
* ## About
|
|
312
338
|
* @package @ktjs/core
|
|
313
339
|
* @author Kasukabe Tsumugi <futami16237@gmail.com>
|
|
314
|
-
* @version 0.
|
|
340
|
+
* @version 0.23.0 (Last Update: 2026.02.03 17:15:01.812)
|
|
315
341
|
* @license MIT
|
|
316
342
|
* @link https://github.com/baendlorel/kt.js
|
|
317
343
|
* @link https://baendlorel.github.io/ Welcome to my site!
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ktjs/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.23.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.22.
|
|
47
|
+
"@ktjs/shared": "0.22.3"
|
|
48
48
|
},
|
|
49
49
|
"scripts": {
|
|
50
50
|
"build": "rollup -c rollup.config.mjs",
|