rumious 2.0.0 → 2.0.1
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.js +8 -3
- package/dist/jsx/element.d.ts +1 -1
- package/package.json +2 -2
- package/src/jsx/element.ts +14 -7
package/dist/index.js
CHANGED
@@ -645,9 +645,14 @@ function appendChild(parent, node) {
|
|
645
645
|
parent.appendChild(node);
|
646
646
|
}
|
647
647
|
function element(parent, tagName, attrs) {
|
648
|
-
|
649
|
-
|
650
|
-
|
648
|
+
const el = document.createElement(tagName);
|
649
|
+
if (attrs) {
|
650
|
+
for (let key in attrs) {
|
651
|
+
el.setAttribute(key, attrs[key]);
|
652
|
+
}
|
653
|
+
}
|
654
|
+
parent.appendChild(el);
|
655
|
+
return el;
|
651
656
|
}
|
652
657
|
function replaceNode(oldNode, newNode) {
|
653
658
|
const parent = oldNode.parentNode;
|
package/dist/jsx/element.d.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
export declare function appendChild(parent: HTMLElement, node: Node | string): void;
|
2
|
-
export declare function element(parent: HTMLElement, tagName: string, attrs
|
2
|
+
export declare function element(parent: HTMLElement, tagName: string, attrs?: Record<string, any>): HTMLElement;
|
3
3
|
export declare function replaceNode(oldNode: Node, newNode: Node): void;
|
4
4
|
interface RumiousEventTarget extends HTMLElement {
|
5
5
|
__rumiousEvents?: Record<string, (e: Event) => void>;
|
package/package.json
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
{
|
2
2
|
"name": "rumious",
|
3
|
-
"version": "2.0.
|
3
|
+
"version": "2.0.1",
|
4
4
|
"description": "",
|
5
5
|
"main": "dist/index.js",
|
6
6
|
"types": "dist/index.d.ts",
|
7
7
|
"exports": {
|
8
8
|
".": {
|
9
9
|
"import": "./dist/index.js",
|
10
|
-
"
|
10
|
+
"default": "./dist/index.js"
|
11
11
|
}
|
12
12
|
},
|
13
13
|
"scripts": {
|
package/src/jsx/element.ts
CHANGED
@@ -8,13 +8,20 @@ export function appendChild(
|
|
8
8
|
}
|
9
9
|
|
10
10
|
export function element(
|
11
|
-
parent:HTMLElement,
|
12
|
-
tagName:string,
|
13
|
-
attrs: Record<string,any>
|
14
|
-
):HTMLElement{
|
15
|
-
|
16
|
-
|
17
|
-
|
11
|
+
parent: HTMLElement,
|
12
|
+
tagName: string,
|
13
|
+
attrs ? : Record < string, any >
|
14
|
+
): HTMLElement {
|
15
|
+
const el = document.createElement(tagName);
|
16
|
+
|
17
|
+
if (attrs) {
|
18
|
+
for (let key in attrs) {
|
19
|
+
el.setAttribute(key, attrs[key]);
|
20
|
+
}
|
21
|
+
}
|
22
|
+
|
23
|
+
parent.appendChild(el);
|
24
|
+
return el;
|
18
25
|
}
|
19
26
|
|
20
27
|
|