@ktjs/core 0.15.1 → 0.15.2

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 CHANGED
@@ -139,10 +139,6 @@ type KTComponent = (
139
139
  ) => KTHTMLElement | Promise<KTHTMLElement> | any;
140
140
 
141
141
  type HTML<T extends HTMLTag & otherstring> = T extends HTMLTag ? HTMLElementTagNameMap[T] : HTMLElement;
142
- type H = (<T extends HTMLTag>(tag: T, attr?: KTRawAttr, content?: KTRawContent) => HTML<T>) & {
143
- kDepth: number;
144
- kUpdater: (() => void)[];
145
- };
146
142
  /**
147
143
  * Create an enhanced HTMLElement.
148
144
  * - Only supports HTMLElements, **NOT** SVGElements or other Elements.
@@ -153,14 +149,14 @@ type H = (<T extends HTMLTag>(tag: T, attr?: KTRawAttr, content?: KTRawContent)
153
149
  * ## About
154
150
  * @package @ktjs/core
155
151
  * @author Kasukabe Tsumugi <futami16237@gmail.com>
156
- * @version 0.15.1 (Last Update: 2026.01.25 13:09:33.161)
152
+ * @version 0.15.2 (Last Update: 2026.01.25 14:25:37.357)
157
153
  * @license MIT
158
154
  * @link https://github.com/baendlorel/kt.js
159
155
  * @link https://baendlorel.github.io/ Welcome to my site!
160
156
  * @description Core functionality for kt.js - DOM manipulation utilities with JSX/TSX support
161
157
  * @copyright Copyright (c) 2026 Kasukabe Tsumugi. All rights reserved.
162
158
  */
163
- declare const h: H;
159
+ declare const h: <T extends HTMLTag>(tag: T, attr?: KTRawAttr, content?: KTRawContent) => HTML<T>;
164
160
 
165
161
  type JSXTag = HTMLTag | ((props?: any) => HTMLElement) | ((props?: any) => Promise<HTMLElement>) | ((props?: any) => KTHTMLElement) | ((props?: any) => Promise<KTHTMLElement>);
166
162
  /**
@@ -194,6 +194,9 @@ var __ktjs_core__ = (function (exports) {
194
194
  }
195
195
  }
196
196
 
197
+ const defaultCreator = (tag) => document.createElement(tag);
198
+ const svgCreator = (tag) => document.createElementNS('http://www.w3.org/1999/xhtml', tag);
199
+ let creator = defaultCreator;
197
200
  /**
198
201
  * Create an enhanced HTMLElement.
199
202
  * - Only supports HTMLElements, **NOT** SVGElements or other Elements.
@@ -204,24 +207,29 @@ var __ktjs_core__ = (function (exports) {
204
207
  * ## About
205
208
  * @package @ktjs/core
206
209
  * @author Kasukabe Tsumugi <futami16237@gmail.com>
207
- * @version 0.15.1 (Last Update: 2026.01.25 13:09:33.161)
210
+ * @version 0.15.2 (Last Update: 2026.01.25 14:25:37.357)
208
211
  * @license MIT
209
212
  * @link https://github.com/baendlorel/kt.js
210
213
  * @link https://baendlorel.github.io/ Welcome to my site!
211
214
  * @description Core functionality for kt.js - DOM manipulation utilities with JSX/TSX support
212
215
  * @copyright Copyright (c) 2026 Kasukabe Tsumugi. All rights reserved.
213
216
  */
214
- const h = ((tag, attr = '', content = '') => {
217
+ const h = (tag, attr, content) => {
215
218
  if (typeof tag !== 'string') {
216
219
  $throw('tagName must be a string.');
217
220
  }
221
+ let lastCreator = creator;
222
+ if (tag === 'svg') {
223
+ creator = svgCreator;
224
+ }
218
225
  // * start creating the element
219
- const element = document.createElement(tag);
226
+ const element = creator(tag);
220
227
  // * Handle content
221
228
  applyAttr(element, attr);
222
229
  applyContent(element, content);
230
+ creator = lastCreator; // restore previous creator
223
231
  return element;
224
- });
232
+ };
225
233
 
226
234
  /**
227
235
  * Reference to the created HTML element.
@@ -219,6 +219,9 @@ var __ktjs_core__ = (function (exports) {
219
219
  }
220
220
  }
221
221
 
222
+ var defaultCreator = function (tag) { return document.createElement(tag); };
223
+ var svgCreator = function (tag) { return document.createElementNS('http://www.w3.org/1999/xhtml', tag); };
224
+ var creator = defaultCreator;
222
225
  /**
223
226
  * Create an enhanced HTMLElement.
224
227
  * - Only supports HTMLElements, **NOT** SVGElements or other Elements.
@@ -229,26 +232,29 @@ var __ktjs_core__ = (function (exports) {
229
232
  * ## About
230
233
  * @package @ktjs/core
231
234
  * @author Kasukabe Tsumugi <futami16237@gmail.com>
232
- * @version 0.15.1 (Last Update: 2026.01.25 13:09:33.161)
235
+ * @version 0.15.2 (Last Update: 2026.01.25 14:25:37.357)
233
236
  * @license MIT
234
237
  * @link https://github.com/baendlorel/kt.js
235
238
  * @link https://baendlorel.github.io/ Welcome to my site!
236
239
  * @description Core functionality for kt.js - DOM manipulation utilities with JSX/TSX support
237
240
  * @copyright Copyright (c) 2026 Kasukabe Tsumugi. All rights reserved.
238
241
  */
239
- var h = (function (tag, attr, content) {
240
- if (attr === void 0) { attr = ''; }
241
- if (content === void 0) { content = ''; }
242
+ var h = function (tag, attr, content) {
242
243
  if (typeof tag !== 'string') {
243
244
  $throw('tagName must be a string.');
244
245
  }
246
+ var lastCreator = creator;
247
+ if (tag === 'svg') {
248
+ creator = svgCreator;
249
+ }
245
250
  // * start creating the element
246
- var element = document.createElement(tag);
251
+ var element = creator(tag);
247
252
  // * Handle content
248
253
  applyAttr(element, attr);
249
254
  applyContent(element, content);
255
+ creator = lastCreator; // restore previous creator
250
256
  return element;
251
- });
257
+ };
252
258
 
253
259
  /******************************************************************************
254
260
  Copyright (c) Microsoft Corporation.
package/dist/index.mjs CHANGED
@@ -191,6 +191,9 @@ function applyContent(element, content) {
191
191
  }
192
192
  }
193
193
 
194
+ const defaultCreator = (tag) => document.createElement(tag);
195
+ const svgCreator = (tag) => document.createElementNS('http://www.w3.org/1999/xhtml', tag);
196
+ let creator = defaultCreator;
194
197
  /**
195
198
  * Create an enhanced HTMLElement.
196
199
  * - Only supports HTMLElements, **NOT** SVGElements or other Elements.
@@ -201,24 +204,29 @@ function applyContent(element, content) {
201
204
  * ## About
202
205
  * @package @ktjs/core
203
206
  * @author Kasukabe Tsumugi <futami16237@gmail.com>
204
- * @version 0.15.1 (Last Update: 2026.01.25 13:09:33.161)
207
+ * @version 0.15.2 (Last Update: 2026.01.25 14:25:37.357)
205
208
  * @license MIT
206
209
  * @link https://github.com/baendlorel/kt.js
207
210
  * @link https://baendlorel.github.io/ Welcome to my site!
208
211
  * @description Core functionality for kt.js - DOM manipulation utilities with JSX/TSX support
209
212
  * @copyright Copyright (c) 2026 Kasukabe Tsumugi. All rights reserved.
210
213
  */
211
- const h = ((tag, attr = '', content = '') => {
214
+ const h = (tag, attr, content) => {
212
215
  if (typeof tag !== 'string') {
213
216
  $throw('tagName must be a string.');
214
217
  }
218
+ let lastCreator = creator;
219
+ if (tag === 'svg') {
220
+ creator = svgCreator;
221
+ }
215
222
  // * start creating the element
216
- const element = document.createElement(tag);
223
+ const element = creator(tag);
217
224
  // * Handle content
218
225
  applyAttr(element, attr);
219
226
  applyContent(element, content);
227
+ creator = lastCreator; // restore previous creator
220
228
  return element;
221
- });
229
+ };
222
230
 
223
231
  /**
224
232
  * Reference to the created HTML element.
@@ -125,10 +125,6 @@ type KTSpecialEventHandlers = {
125
125
  type KTAttribute = KTBaseAttribute & KTPrefixedEventHandlers & KTSpecialEventHandlers;
126
126
 
127
127
  type HTML<T extends HTMLTag & otherstring> = T extends HTMLTag ? HTMLElementTagNameMap[T] : HTMLElement;
128
- type H = (<T extends HTMLTag>(tag: T, attr?: KTRawAttr, content?: KTRawContent) => HTML<T>) & {
129
- kDepth: number;
130
- kUpdater: (() => void)[];
131
- };
132
128
  /**
133
129
  * Create an enhanced HTMLElement.
134
130
  * - Only supports HTMLElements, **NOT** SVGElements or other Elements.
@@ -139,14 +135,14 @@ type H = (<T extends HTMLTag>(tag: T, attr?: KTRawAttr, content?: KTRawContent)
139
135
  * ## About
140
136
  * @package @ktjs/core
141
137
  * @author Kasukabe Tsumugi <futami16237@gmail.com>
142
- * @version 0.15.1 (Last Update: 2026.01.25 13:09:33.161)
138
+ * @version 0.15.2 (Last Update: 2026.01.25 14:25:37.357)
143
139
  * @license MIT
144
140
  * @link https://github.com/baendlorel/kt.js
145
141
  * @link https://baendlorel.github.io/ Welcome to my site!
146
142
  * @description Core functionality for kt.js - DOM manipulation utilities with JSX/TSX support
147
143
  * @copyright Copyright (c) 2026 Kasukabe Tsumugi. All rights reserved.
148
144
  */
149
- declare const h: H;
145
+ declare const h: <T extends HTMLTag>(tag: T, attr?: KTRawAttr, content?: KTRawContent) => HTML<T>;
150
146
 
151
147
  type JSXTag = HTMLTag | ((props?: any) => HTMLElement) | ((props?: any) => Promise<HTMLElement>) | ((props?: any) => KTHTMLElement) | ((props?: any) => Promise<KTHTMLElement>);
152
148
  /**
@@ -191,6 +191,9 @@ function applyContent(element, content) {
191
191
  }
192
192
  }
193
193
 
194
+ const defaultCreator = (tag) => document.createElement(tag);
195
+ const svgCreator = (tag) => document.createElementNS('http://www.w3.org/1999/xhtml', tag);
196
+ let creator = defaultCreator;
194
197
  /**
195
198
  * Create an enhanced HTMLElement.
196
199
  * - Only supports HTMLElements, **NOT** SVGElements or other Elements.
@@ -201,24 +204,29 @@ function applyContent(element, content) {
201
204
  * ## About
202
205
  * @package @ktjs/core
203
206
  * @author Kasukabe Tsumugi <futami16237@gmail.com>
204
- * @version 0.15.1 (Last Update: 2026.01.25 13:09:33.161)
207
+ * @version 0.15.2 (Last Update: 2026.01.25 14:25:37.357)
205
208
  * @license MIT
206
209
  * @link https://github.com/baendlorel/kt.js
207
210
  * @link https://baendlorel.github.io/ Welcome to my site!
208
211
  * @description Core functionality for kt.js - DOM manipulation utilities with JSX/TSX support
209
212
  * @copyright Copyright (c) 2026 Kasukabe Tsumugi. All rights reserved.
210
213
  */
211
- const h = ((tag, attr = '', content = '') => {
214
+ const h = (tag, attr, content) => {
212
215
  if (typeof tag !== 'string') {
213
216
  $throw('tagName must be a string.');
214
217
  }
218
+ let lastCreator = creator;
219
+ if (tag === 'svg') {
220
+ creator = svgCreator;
221
+ }
215
222
  // * start creating the element
216
- const element = document.createElement(tag);
223
+ const element = creator(tag);
217
224
  // * Handle content
218
225
  applyAttr(element, attr);
219
226
  applyContent(element, content);
227
+ creator = lastCreator; // restore previous creator
220
228
  return element;
221
- });
229
+ };
222
230
 
223
231
  /**
224
232
  * Reference to the created HTML element.
@@ -119,10 +119,6 @@ type KTSpecialEventHandlers = {
119
119
  type KTAttribute = KTBaseAttribute & KTPrefixedEventHandlers & KTSpecialEventHandlers;
120
120
 
121
121
  type HTML<T extends HTMLTag & otherstring> = T extends HTMLTag ? HTMLElementTagNameMap[T] : HTMLElement;
122
- type H = (<T extends HTMLTag>(tag: T, attr?: KTRawAttr, content?: KTRawContent) => HTML<T>) & {
123
- kDepth: number;
124
- kUpdater: (() => void)[];
125
- };
126
122
  /**
127
123
  * Create an enhanced HTMLElement.
128
124
  * - Only supports HTMLElements, **NOT** SVGElements or other Elements.
@@ -133,14 +129,14 @@ type H = (<T extends HTMLTag>(tag: T, attr?: KTRawAttr, content?: KTRawContent)
133
129
  * ## About
134
130
  * @package @ktjs/core
135
131
  * @author Kasukabe Tsumugi <futami16237@gmail.com>
136
- * @version 0.15.1 (Last Update: 2026.01.25 13:09:33.161)
132
+ * @version 0.15.2 (Last Update: 2026.01.25 14:25:37.357)
137
133
  * @license MIT
138
134
  * @link https://github.com/baendlorel/kt.js
139
135
  * @link https://baendlorel.github.io/ Welcome to my site!
140
136
  * @description Core functionality for kt.js - DOM manipulation utilities with JSX/TSX support
141
137
  * @copyright Copyright (c) 2026 Kasukabe Tsumugi. All rights reserved.
142
138
  */
143
- declare const h: H;
139
+ declare const h: <T extends HTMLTag>(tag: T, attr?: KTRawAttr, content?: KTRawContent) => HTML<T>;
144
140
 
145
141
  type JSXTag = HTMLTag | ((props?: any) => HTMLElement) | ((props?: any) => Promise<HTMLElement>) | ((props?: any) => KTHTMLElement) | ((props?: any) => Promise<KTHTMLElement>);
146
142
  /**
@@ -191,6 +191,9 @@ function applyContent(element, content) {
191
191
  }
192
192
  }
193
193
 
194
+ const defaultCreator = (tag) => document.createElement(tag);
195
+ const svgCreator = (tag) => document.createElementNS('http://www.w3.org/1999/xhtml', tag);
196
+ let creator = defaultCreator;
194
197
  /**
195
198
  * Create an enhanced HTMLElement.
196
199
  * - Only supports HTMLElements, **NOT** SVGElements or other Elements.
@@ -201,24 +204,29 @@ function applyContent(element, content) {
201
204
  * ## About
202
205
  * @package @ktjs/core
203
206
  * @author Kasukabe Tsumugi <futami16237@gmail.com>
204
- * @version 0.15.1 (Last Update: 2026.01.25 13:09:33.161)
207
+ * @version 0.15.2 (Last Update: 2026.01.25 14:25:37.357)
205
208
  * @license MIT
206
209
  * @link https://github.com/baendlorel/kt.js
207
210
  * @link https://baendlorel.github.io/ Welcome to my site!
208
211
  * @description Core functionality for kt.js - DOM manipulation utilities with JSX/TSX support
209
212
  * @copyright Copyright (c) 2026 Kasukabe Tsumugi. All rights reserved.
210
213
  */
211
- const h = ((tag, attr = '', content = '') => {
214
+ const h = (tag, attr, content) => {
212
215
  if (typeof tag !== 'string') {
213
216
  $throw('tagName must be a string.');
214
217
  }
218
+ let lastCreator = creator;
219
+ if (tag === 'svg') {
220
+ creator = svgCreator;
221
+ }
215
222
  // * start creating the element
216
- const element = document.createElement(tag);
223
+ const element = creator(tag);
217
224
  // * Handle content
218
225
  applyAttr(element, attr);
219
226
  applyContent(element, content);
227
+ creator = lastCreator; // restore previous creator
220
228
  return element;
221
- });
229
+ };
222
230
 
223
231
  /**
224
232
  * Reference to the created HTML element.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ktjs/core",
3
- "version": "0.15.1",
3
+ "version": "0.15.2",
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",