tkeron 3.3.0 → 3.4.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/changelog.md CHANGED
@@ -1,3 +1,9 @@
1
+ # v3.4.0
2
+
3
+ - update tkeron library
4
+ - Add childs property
5
+ - Add "addChilds" method
6
+
1
7
  # v3.3.0
2
8
 
3
9
  - update tkeron lilbrary
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tkeron",
3
- "version": "3.3.0",
3
+ "version": "3.4.0",
4
4
  "description": "Micro framework for developing web user interfaces with typescript.",
5
5
  "bin": {
6
6
  "tkeron": "dist/index.js",
@@ -0,0 +1,12 @@
1
+ import { TkeronElement } from "./element";
2
+
3
+ export const addChilds = (com: TkeronElement) => {
4
+ com.addChilds = (...elements) => {
5
+ for (const element of elements) {
6
+ com.childs.push(element);
7
+ com.htmlElement.appendChild(element.htmlElement);
8
+ }
9
+
10
+ return com;
11
+ };
12
+ };
@@ -2,6 +2,7 @@ import { appendIn } from "./appendIn";
2
2
  import { setAttribute } from "./setAttribute";
3
3
  import { setHtml, setText } from "./setHtml_setText";
4
4
  import { addClass, removeClass } from "./addClass_removeClass";
5
+ import { addChilds } from "./addChilds";
5
6
 
6
7
  export interface TkeronElement {
7
8
  htmlElement: HTMLElement;
@@ -15,6 +16,8 @@ export interface TkeronElement {
15
16
  setAttribute: (attribute: string, value: string) => TkeronElement;
16
17
  addClass: (...className) => TkeronElement;
17
18
  removeClass: (...className) => TkeronElement;
19
+ childs: TkeronElement[];
20
+ addChilds: (...childs: TkeronElement[]) => TkeronElement;
18
21
  }
19
22
 
20
23
  export interface TkeronElementArguments {
@@ -41,6 +44,7 @@ export const tk = <TkeronElementAuto>((
41
44
 
42
45
  const com = <TkeronElement>{
43
46
  htmlElement: document.createElement(tag),
47
+ childs: childs || [],
44
48
  };
45
49
 
46
50
  //init chaining methods
@@ -50,9 +54,11 @@ export const tk = <TkeronElementAuto>((
50
54
  setAttribute(com);
51
55
  addClass(com);
52
56
  removeClass(com);
57
+ addChilds(com);
53
58
 
54
59
  if (childs)
55
60
  for (const child of childs) {
61
+ com.childs.push(child);
56
62
  com.htmlElement.appendChild(child.htmlElement);
57
63
  }
58
64
 
@@ -67,6 +73,8 @@ for (const attribute of [
67
73
  "setAttribute",
68
74
  "addClass",
69
75
  "removeClass",
76
+ "childs",
77
+ "addChilds"
70
78
  ]) {
71
79
  Object.defineProperty(tk, attribute, {
72
80
  get() {
File without changes