domelemjs 1.0.13 → 1.1.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/README.md +2 -2
- package/index.js +105 -192
- package/index.min.js +1 -1
- package/index.min.js.map +52 -56
- package/package.json +1 -1
- package/test/DOMElem.html +23 -26
- package/test/createDOMElem.html +19 -5
package/README.md
CHANGED
package/index.js
CHANGED
|
@@ -1,121 +1,3 @@
|
|
|
1
|
-
const noSpecChars = (text, lowercase = false) => {
|
|
2
|
-
function replaceAll(string, search, replace) {
|
|
3
|
-
return string.split(search).join(replace);
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
let specialChars = {
|
|
7
|
-
é: "e",
|
|
8
|
-
á: "a",
|
|
9
|
-
ó: "o",
|
|
10
|
-
ö: "o",
|
|
11
|
-
ő: "o",
|
|
12
|
-
ú: "u",
|
|
13
|
-
ü: "u",
|
|
14
|
-
ű: "u",
|
|
15
|
-
í: "i",
|
|
16
|
-
É: "E",
|
|
17
|
-
Á: "A",
|
|
18
|
-
Ó: "O",
|
|
19
|
-
Ö: "O",
|
|
20
|
-
Ő: "O",
|
|
21
|
-
Ú: "U",
|
|
22
|
-
Ü: "U",
|
|
23
|
-
Ű: "U",
|
|
24
|
-
Í: "I",
|
|
25
|
-
" ": "-",
|
|
26
|
-
"/": "-",
|
|
27
|
-
":": "-",
|
|
28
|
-
";": "-",
|
|
29
|
-
"=": "-",
|
|
30
|
-
};
|
|
31
|
-
for (let char in specialChars) {
|
|
32
|
-
text = replaceAll(text, char, specialChars[char]);
|
|
33
|
-
}
|
|
34
|
-
return lowercase ? text.toLowerCase() : text;
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
const DOMElem = {
|
|
38
|
-
Create: function (parameters) {
|
|
39
|
-
let tag = parameters.tag || "div";
|
|
40
|
-
let attrs = parameters.attrs || {};
|
|
41
|
-
let children = parameters.children || [];
|
|
42
|
-
let eventStarter = parameters.eventStarter || null;
|
|
43
|
-
let eventFunction = parameters.eventFunction || null;
|
|
44
|
-
let content = parameters.content || null;
|
|
45
|
-
let text = parameters.text || null;
|
|
46
|
-
let style = parameters.style || null;
|
|
47
|
-
|
|
48
|
-
let targetParent =
|
|
49
|
-
typeof parameters.targetParent == "string"
|
|
50
|
-
? document.getElementById(parameters.targetParent) ||
|
|
51
|
-
document.querySelector(parameters.targetParent)
|
|
52
|
-
: typeof parameters.targetParent == "object"
|
|
53
|
-
? parameters.targetParent
|
|
54
|
-
: null;
|
|
55
|
-
|
|
56
|
-
let elem = document.createElement(tag);
|
|
57
|
-
|
|
58
|
-
if (content) elem.innerHTML = content;
|
|
59
|
-
if (text) elem.textContent = text;
|
|
60
|
-
|
|
61
|
-
for (let attr in attrs) {
|
|
62
|
-
elem.setAttribute(
|
|
63
|
-
attr,
|
|
64
|
-
attr == "class" || attr == "id" ? noSpecChars(attrs[attr]) : attrs[attr]
|
|
65
|
-
);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/*
|
|
69
|
-
* Adding stye is possible as:
|
|
70
|
-
* * a string, with a bunch of style properties, it can be:
|
|
71
|
-
* * * CCS style (e.g. background-color) or
|
|
72
|
-
* * * JS/camelCase (e.g. backgroundColor) style formatted version also.
|
|
73
|
-
* * or an object formatted (e.g. style: { backgroundColor: red })
|
|
74
|
-
* * or an array with multiple style strings with CSS or JS vesrion, or mixed
|
|
75
|
-
*/
|
|
76
|
-
|
|
77
|
-
if (style) {
|
|
78
|
-
let styleText;
|
|
79
|
-
if (typeof style === "string") {
|
|
80
|
-
styleText = style;
|
|
81
|
-
} else if (Array.isArray(style)) {
|
|
82
|
-
styleText = style.join("; ");
|
|
83
|
-
} else if (typeof style === "object") {
|
|
84
|
-
styleText = [];
|
|
85
|
-
for (let s in style) {
|
|
86
|
-
styleText.push(`${s}: ${style[s]}`);
|
|
87
|
-
}
|
|
88
|
-
styleText = styleText.join("; ");
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
styleText.split(";").forEach((styleText) => {
|
|
92
|
-
let [s, p] = styleText.split(":").map((c) => c.trim());
|
|
93
|
-
s = s
|
|
94
|
-
.split("-")
|
|
95
|
-
.map((ss, i) => {
|
|
96
|
-
return i > 0 ? ss.charAt(0).toUpperCase() + ss.slice(1) : ss;
|
|
97
|
-
})
|
|
98
|
-
.join("");
|
|
99
|
-
elem.style[s] = p;
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
children.map((child) => {
|
|
104
|
-
typeof child != "object"
|
|
105
|
-
? (child = document.createTextNode(child))
|
|
106
|
-
: null;
|
|
107
|
-
elem.appendChild(child);
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
if (eventStarter && eventFunction)
|
|
111
|
-
elem.addEventListener(eventStarter, eventFunction);
|
|
112
|
-
|
|
113
|
-
if (targetParent) targetParent.appendChild(elem);
|
|
114
|
-
|
|
115
|
-
return elem;
|
|
116
|
-
},
|
|
117
|
-
};
|
|
118
|
-
|
|
119
1
|
const createDOMElem = ({
|
|
120
2
|
tag,
|
|
121
3
|
content,
|
|
@@ -144,39 +26,27 @@ const createDOMElem = ({
|
|
|
144
26
|
* add all the attributes they want
|
|
145
27
|
*/
|
|
146
28
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
let attribute;
|
|
164
|
-
if (Array.isArray(attrs[attr])) {
|
|
165
|
-
if (attr === "class") {
|
|
166
|
-
attribute = attrs[attr].map((a) => noSpecChars(a)).join(" ");
|
|
167
|
-
} else {
|
|
168
|
-
attribute = attrs[attr].join(" ");
|
|
169
|
-
}
|
|
170
|
-
} else {
|
|
171
|
-
if (attr === "id") {
|
|
172
|
-
attribute = noSpecChars(attrs[attr]);
|
|
29
|
+
attrs &&
|
|
30
|
+
makeThatArray(attrs).forEach((atts) =>
|
|
31
|
+
Object.keys(atts).forEach((attr) => {
|
|
32
|
+
if (attr === "checked") {
|
|
33
|
+
elem.checked = atts[attr];
|
|
34
|
+
} else if (attr === "dataset") {
|
|
35
|
+
makeThatArray(atts[attr]).map((data) =>
|
|
36
|
+
Object.keys(data).forEach((d) => (elem.dataset[d] = data[d]))
|
|
37
|
+
);
|
|
38
|
+
} else if (attr === "class" || attr === "id") {
|
|
39
|
+
elem.setAttribute(
|
|
40
|
+
attr,
|
|
41
|
+
makeThatArray(atts[attr])
|
|
42
|
+
.map((a) => noSpecChars(a))
|
|
43
|
+
.join(" ")
|
|
44
|
+
);
|
|
173
45
|
} else {
|
|
174
|
-
|
|
46
|
+
elem.setAttribute(attr, makeThatArray(atts[attr]).join(" "));
|
|
175
47
|
}
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
}
|
|
179
|
-
});
|
|
48
|
+
})
|
|
49
|
+
);
|
|
180
50
|
|
|
181
51
|
/*
|
|
182
52
|
* Adding stye is possible as:
|
|
@@ -187,63 +57,41 @@ const createDOMElem = ({
|
|
|
187
57
|
* * or an array with multiple style strings with CSS or JS vesrion, or mixed
|
|
188
58
|
*/
|
|
189
59
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
.
|
|
206
|
-
|
|
207
|
-
return i > 0 ? ss.charAt(0).toUpperCase() + ss.slice(1) : ss;
|
|
208
|
-
})
|
|
209
|
-
.join("");
|
|
210
|
-
elem.style[s] = p;
|
|
211
|
-
});
|
|
212
|
-
}
|
|
60
|
+
style &&
|
|
61
|
+
makeThatArray(style)
|
|
62
|
+
.map((styleElem) => {
|
|
63
|
+
if (typeof styleElem === "object") {
|
|
64
|
+
return Object.keys(styleElem)
|
|
65
|
+
.map((styleTxt) => `${styleTxt}: ${styleElem[styleTxt]}`)
|
|
66
|
+
.join("; ");
|
|
67
|
+
} else {
|
|
68
|
+
return makeThatArray(styleElem).join("; ");
|
|
69
|
+
}
|
|
70
|
+
})
|
|
71
|
+
.join("; ")
|
|
72
|
+
.split(";")
|
|
73
|
+
.forEach((styleTxts) => {
|
|
74
|
+
let [styleTxt, val] = styleTxts.split(":").map((c) => c.trim());
|
|
75
|
+
elem.style[makeCamelCase(styleTxt)] = val;
|
|
76
|
+
});
|
|
213
77
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
if (!Array.isArray(children)) {
|
|
217
|
-
childrenArray.push(children);
|
|
218
|
-
} else {
|
|
219
|
-
childrenArray = [...children];
|
|
220
|
-
}
|
|
221
|
-
childrenArray.map((child) => {
|
|
78
|
+
children &&
|
|
79
|
+
makeThatArray(children).map((child) => {
|
|
222
80
|
let childElem = child;
|
|
223
81
|
if (typeof child === "object") childElem = createDOMElem(child);
|
|
224
82
|
elem.appendChild(childElem);
|
|
225
83
|
});
|
|
226
|
-
}
|
|
227
84
|
|
|
228
85
|
/*
|
|
229
86
|
* Add the eventListener or more eventListeners it hey comes in array
|
|
230
|
-
*/
|
|
231
|
-
let eventsToAdd = [];
|
|
232
|
-
/*
|
|
233
87
|
* Handle event is an object or an array of object, that schould be conain:
|
|
234
88
|
* event, what will fire the event?
|
|
235
89
|
* and a cb, that is the callback function
|
|
236
90
|
*/
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
eventsToAdd = [...handleEvent];
|
|
240
|
-
} else {
|
|
241
|
-
eventsToAdd.push(handleEvent);
|
|
242
|
-
}
|
|
243
|
-
eventsToAdd.forEach((newEvent) => {
|
|
91
|
+
handleEvent &&
|
|
92
|
+
makeThatArray(handleEvent).forEach((newEvent) => {
|
|
244
93
|
elem.addEventListener(newEvent.event, newEvent.cb);
|
|
245
94
|
});
|
|
246
|
-
}
|
|
247
95
|
|
|
248
96
|
/*
|
|
249
97
|
* Append the created elem to the parent what is given, or add to the body of the Document if not given.
|
|
@@ -273,3 +121,68 @@ const createDOMElem = ({
|
|
|
273
121
|
*/
|
|
274
122
|
return elem;
|
|
275
123
|
};
|
|
124
|
+
|
|
125
|
+
/* object caller of the funcion */
|
|
126
|
+
const DOMElem = {
|
|
127
|
+
Create: createDOMElem,
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
/******************/
|
|
131
|
+
/* HELPER METHODS */
|
|
132
|
+
/******************/
|
|
133
|
+
|
|
134
|
+
/* removing special chars form a string */
|
|
135
|
+
const noSpecChars = (text, lowercase = false) => {
|
|
136
|
+
function replaceAll(string, search, replace) {
|
|
137
|
+
return string.split(search).join(replace);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
let specialChars = {
|
|
141
|
+
é: "e",
|
|
142
|
+
á: "a",
|
|
143
|
+
ó: "o",
|
|
144
|
+
ö: "o",
|
|
145
|
+
ő: "o",
|
|
146
|
+
ú: "u",
|
|
147
|
+
ü: "u",
|
|
148
|
+
ű: "u",
|
|
149
|
+
í: "i",
|
|
150
|
+
É: "E",
|
|
151
|
+
Á: "A",
|
|
152
|
+
Ó: "O",
|
|
153
|
+
Ö: "O",
|
|
154
|
+
Ő: "O",
|
|
155
|
+
Ú: "U",
|
|
156
|
+
Ü: "U",
|
|
157
|
+
Ű: "U",
|
|
158
|
+
Í: "I",
|
|
159
|
+
" ": "-",
|
|
160
|
+
"/": "-",
|
|
161
|
+
":": "-",
|
|
162
|
+
";": "-",
|
|
163
|
+
"=": "-",
|
|
164
|
+
};
|
|
165
|
+
for (let char in specialChars) {
|
|
166
|
+
text = replaceAll(text, char, specialChars[char]);
|
|
167
|
+
}
|
|
168
|
+
return lowercase ? text.toLowerCase() : text;
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
/* check is it is array do nothing, if not maki it array */
|
|
172
|
+
const makeThatArray = (arr) => {
|
|
173
|
+
if (Array.isArray(arr)) {
|
|
174
|
+
return arr;
|
|
175
|
+
} else {
|
|
176
|
+
return [arr];
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
/* removing the "-" symbol form the string adn makind the afterward word to uppercase, that is named as camelCase */
|
|
181
|
+
function makeCamelCase(s) {
|
|
182
|
+
return s
|
|
183
|
+
.split("-")
|
|
184
|
+
.map((ss, i) => {
|
|
185
|
+
return i > 0 ? ss.charAt(0).toUpperCase() + ss.slice(1) : ss;
|
|
186
|
+
})
|
|
187
|
+
.join("");
|
|
188
|
+
}
|
package/index.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const
|
|
1
|
+
const createDOMElem=({tag:tag,content:content,text:text,attrs:attrs,style:style,children:children,parent:parent,handleEvent:handleEvent})=>{let elem=document.createElement(tag);return content&&(elem.innerHTML=content),text&&(elem.textContent=text),attrs&&makeThatArray(attrs).forEach(atts=>Object.keys(atts).forEach(attr=>{"checked"===attr?elem.checked=atts[attr]:"dataset"===attr?makeThatArray(atts[attr]).map(data=>Object.keys(data).forEach(d=>elem.dataset[d]=data[d])):"class"===attr||"id"===attr?elem.setAttribute(attr,makeThatArray(atts[attr]).map(a=>noSpecChars(a)).join(" ")):elem.setAttribute(attr,makeThatArray(atts[attr]).join(" "))})),style&&makeThatArray(style).map(styleElem=>"object"==typeof styleElem?Object.keys(styleElem).map(styleTxt=>`${styleTxt}: ${styleElem[styleTxt]}`).join("; "):makeThatArray(styleElem).join("; ")).join("; ").split(";").forEach(styleTxts=>{let[styleTxt,val]=styleTxts.split(":").map(c=>c.trim());elem.style[makeCamelCase(styleTxt)]=val}),children&&makeThatArray(children).map(child=>{let childElem=child;"object"==typeof child&&(childElem=createDOMElem(child)),elem.appendChild(childElem)}),handleEvent&&makeThatArray(handleEvent).forEach(newEvent=>{elem.addEventListener(newEvent.event,newEvent.cb)}),parent?"string"==typeof parent&&(parent=[".","#"].map(prep=>document.querySelector(prep+parent)).filter(pe=>null!==pe)[0]):parent=document.querySelector("body"),parent.appendChild(elem),elem},DOMElem={Create:createDOMElem},noSpecChars=(text,lowercase=!1)=>{function replaceAll(string,search,replace){return string.split(search).join(replace)}let specialChars={"é":"e","á":"a","ó":"o","ö":"o","ő":"o","ú":"u","ü":"u","ű":"u","í":"i","É":"E","Á":"A","Ó":"O","Ö":"O","Ő":"O","Ú":"U","Ü":"U","Ű":"U","Í":"I"," ":"-","/":"-",":":"-",";":"-","=":"-"};for(let char in specialChars)text=replaceAll(text,char,specialChars[char]);return lowercase?text.toLowerCase():text},makeThatArray=arr=>Array.isArray(arr)?arr:[arr];function makeCamelCase(s){return s.split("-").map((ss,i)=>i>0?ss.charAt(0).toUpperCase()+ss.slice(1):ss).join("")}
|
|
2
2
|
//# sourceMappingURL=index.min.js.map
|
package/index.min.js.map
CHANGED
|
@@ -4,15 +4,61 @@
|
|
|
4
4
|
"index.js"
|
|
5
5
|
],
|
|
6
6
|
"names": [
|
|
7
|
-
"
|
|
7
|
+
"createDOMElem",
|
|
8
|
+
"tag",
|
|
9
|
+
"content",
|
|
8
10
|
"text",
|
|
11
|
+
"attrs",
|
|
12
|
+
"style",
|
|
13
|
+
"children",
|
|
14
|
+
"parent",
|
|
15
|
+
"handleEvent",
|
|
16
|
+
"elem",
|
|
17
|
+
"document",
|
|
18
|
+
"createElement",
|
|
19
|
+
"innerHTML",
|
|
20
|
+
"textContent",
|
|
21
|
+
"makeThatArray",
|
|
22
|
+
"forEach",
|
|
23
|
+
"atts",
|
|
24
|
+
"Object",
|
|
25
|
+
"keys",
|
|
26
|
+
"attr",
|
|
27
|
+
"checked",
|
|
28
|
+
"map",
|
|
29
|
+
"data",
|
|
30
|
+
"d",
|
|
31
|
+
"dataset",
|
|
32
|
+
"setAttribute",
|
|
33
|
+
"a",
|
|
34
|
+
"noSpecChars",
|
|
35
|
+
"join",
|
|
36
|
+
"styleElem",
|
|
37
|
+
"styleTxt",
|
|
38
|
+
"split",
|
|
39
|
+
"styleTxts",
|
|
40
|
+
"val",
|
|
41
|
+
"c",
|
|
42
|
+
"trim",
|
|
43
|
+
"makeCamelCase",
|
|
44
|
+
"child",
|
|
45
|
+
"childElem",
|
|
46
|
+
"appendChild",
|
|
47
|
+
"newEvent",
|
|
48
|
+
"addEventListener",
|
|
49
|
+
"event",
|
|
50
|
+
"cb",
|
|
51
|
+
"prep",
|
|
52
|
+
"querySelector",
|
|
53
|
+
"filter",
|
|
54
|
+
"pe",
|
|
55
|
+
"DOMElem",
|
|
56
|
+
"Create",
|
|
9
57
|
"lowercase",
|
|
10
58
|
"replaceAll",
|
|
11
59
|
"string",
|
|
12
60
|
"search",
|
|
13
61
|
"replace",
|
|
14
|
-
"split",
|
|
15
|
-
"join",
|
|
16
62
|
"specialChars",
|
|
17
63
|
"é",
|
|
18
64
|
"á",
|
|
@@ -39,66 +85,16 @@
|
|
|
39
85
|
"=",
|
|
40
86
|
"char",
|
|
41
87
|
"toLowerCase",
|
|
42
|
-
"
|
|
43
|
-
"Create",
|
|
44
|
-
"parameters",
|
|
45
|
-
"tag",
|
|
46
|
-
"attrs",
|
|
47
|
-
"children",
|
|
48
|
-
"eventStarter",
|
|
49
|
-
"eventFunction",
|
|
50
|
-
"content",
|
|
51
|
-
"style",
|
|
52
|
-
"targetParent",
|
|
53
|
-
"document",
|
|
54
|
-
"getElementById",
|
|
55
|
-
"querySelector",
|
|
56
|
-
"elem",
|
|
57
|
-
"createElement",
|
|
58
|
-
"innerHTML",
|
|
59
|
-
"textContent",
|
|
60
|
-
"attr",
|
|
61
|
-
"setAttribute",
|
|
62
|
-
"styleText",
|
|
88
|
+
"arr",
|
|
63
89
|
"Array",
|
|
64
90
|
"isArray",
|
|
65
91
|
"s",
|
|
66
|
-
"push",
|
|
67
|
-
"forEach",
|
|
68
|
-
"p",
|
|
69
|
-
"map",
|
|
70
|
-
"c",
|
|
71
|
-
"trim",
|
|
72
92
|
"ss",
|
|
73
93
|
"i",
|
|
74
94
|
"charAt",
|
|
75
95
|
"toUpperCase",
|
|
76
|
-
"slice"
|
|
77
|
-
"child",
|
|
78
|
-
"createTextNode",
|
|
79
|
-
"appendChild",
|
|
80
|
-
"addEventListener",
|
|
81
|
-
"createDOMElem",
|
|
82
|
-
"parent",
|
|
83
|
-
"handleEvent",
|
|
84
|
-
"Object",
|
|
85
|
-
"keys",
|
|
86
|
-
"checked",
|
|
87
|
-
"dataset",
|
|
88
|
-
"data",
|
|
89
|
-
"d",
|
|
90
|
-
"attribute",
|
|
91
|
-
"a",
|
|
92
|
-
"childrenArray",
|
|
93
|
-
"childElem",
|
|
94
|
-
"eventsToAdd",
|
|
95
|
-
"newEvent",
|
|
96
|
-
"event",
|
|
97
|
-
"cb",
|
|
98
|
-
"prep",
|
|
99
|
-
"filter",
|
|
100
|
-
"pe"
|
|
96
|
+
"slice"
|
|
101
97
|
],
|
|
102
|
-
"mappings": "AAAA,MAAMA,
|
|
98
|
+
"mappings": "AAAA,MAAMA,cAAgB,EACpBC,IAAAA,IACAC,QAAAA,QACAC,KAAAA,KACAC,MAAAA,MACAC,MAAAA,MACAC,SAAAA,SACAC,OAAAA,OACAC,YAAAA,gBAKA,IAAIC,KAAOC,SAASC,cAAcV,KA4GlC,OAvGAC,UAAYO,KAAKG,UAAYV,SAI7BC,OAASM,KAAKI,YAAcV,MAM5BC,OACEU,cAAcV,OAAOW,QAASC,MAC5BC,OAAOC,KAAKF,MAAMD,QAASI,OACZ,YAATA,KACFV,KAAKW,QAAUJ,KAAKG,MACF,YAATA,KACTL,cAAcE,KAAKG,OAAOE,IAAKC,MAC7BL,OAAOC,KAAKI,MAAMP,QAASQ,GAAOd,KAAKe,QAAQD,GAAKD,KAAKC,KAEzC,UAATJ,MAA6B,OAATA,KAC7BV,KAAKgB,aACHN,KACAL,cAAcE,KAAKG,OAChBE,IAAKK,GAAMC,YAAYD,IACvBE,KAAK,MAGVnB,KAAKgB,aAAaN,KAAML,cAAcE,KAAKG,OAAOS,KAAK,SAc/DvB,OACES,cAAcT,OACXgB,IAAKQ,WACqB,iBAAdA,UACFZ,OAAOC,KAAKW,WAChBR,IAAKS,UAAa,GAAGA,aAAaD,UAAUC,aAC5CF,KAAK,MAEDd,cAAce,WAAWD,KAAK,OAGxCA,KAAK,MACLG,MAAM,KACNhB,QAASiB,YACR,IAAKF,SAAUG,KAAOD,UAAUD,MAAM,KAAKV,IAAKa,GAAMA,EAAEC,QACxD1B,KAAKJ,MAAM+B,cAAcN,WAAaG,MAG5C3B,UACEQ,cAAcR,UAAUe,IAAKgB,QAC3B,IAAIC,UAAYD,MACK,iBAAVA,QAAoBC,UAAYtC,cAAcqC,QACzD5B,KAAK8B,YAAYD,aASrB9B,aACEM,cAAcN,aAAaO,QAASyB,WAClC/B,KAAKgC,iBAAiBD,SAASE,MAAOF,SAASG,MAY/CpC,OACoB,iBAAXA,SACTA,OAAS,CAAC,IAAK,KACZc,IAAKuB,MACGlC,SAASmC,cAAcD,KAAOrC,SAEtCuC,OAAQC,IACO,OAAPA,IACN,IAEFxC,OAASG,SAASmC,cAAc,QAEvCtC,OAAOgC,YAAY9B,MAKZA,MAIHuC,QAAU,CACdC,OAAQjD,eAQJ2B,YAAc,CAACxB,KAAM+C,WAAY,KACrC,SAASC,WAAWC,OAAQC,OAAQC,SAClC,OAAOF,OAAOrB,MAAMsB,QAAQzB,KAAK0B,SAGnC,IAAIC,aAAe,CACjBC,IAAG,IACHC,IAAG,IACHC,IAAG,IACHC,IAAG,IACHC,IAAG,IACHC,IAAG,IACHC,IAAG,IACHC,IAAG,IACHC,IAAG,IACHC,IAAG,IACHC,IAAG,IACHC,IAAG,IACHC,IAAG,IACHC,IAAG,IACHC,IAAG,IACHC,IAAG,IACHC,IAAG,IACHC,IAAG,IACHC,IAAK,IACLC,IAAK,IACLC,IAAK,IACLC,IAAK,IACLC,IAAK,KAEP,IAAK,IAAIC,QAAQxB,aACfpD,KAAOgD,WAAWhD,KAAM4E,KAAMxB,aAAawB,OAE7C,OAAO7B,UAAY/C,KAAK6E,cAAgB7E,MAIpCW,cAAiBmE,KACjBC,MAAMC,QAAQF,KACTA,IAEA,CAACA,KAKZ,SAAS7C,cAAcgD,GACrB,OAAOA,EACJrD,MAAM,KACNV,IAAI,CAACgE,GAAIC,IACDA,EAAI,EAAID,GAAGE,OAAO,GAAGC,cAAgBH,GAAGI,MAAM,GAAKJ,IAE3DzD,KAAK",
|
|
103
99
|
"file": "index.js"
|
|
104
100
|
}
|
package/package.json
CHANGED
package/test/DOMElem.html
CHANGED
|
@@ -25,53 +25,50 @@
|
|
|
25
25
|
/* 2. Úgy is használhatom, hogy a szülőelemet már az Elem létrehozásakor megadom neki, és akkor befűzi oda. */
|
|
26
26
|
|
|
27
27
|
function generateOption(options) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
let optionElem = DOMElem.Create({
|
|
28
|
+
return options.map((option) =>
|
|
29
|
+
DOMElem.Create({
|
|
31
30
|
tag: "option",
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
optionElems.push(optionElem);
|
|
36
|
-
});
|
|
37
|
-
return optionElems;
|
|
31
|
+
text: option,
|
|
32
|
+
})
|
|
33
|
+
);
|
|
38
34
|
}
|
|
39
35
|
|
|
40
36
|
let animals = ["Maci", "Nyuszi", "Cica", "Kutya"];
|
|
41
37
|
let animalOption = generateOption(animals);
|
|
42
38
|
|
|
39
|
+
myDOM.selectControl = DOMElem.Create({
|
|
40
|
+
tag: "label",
|
|
41
|
+
text: "állatkák:",
|
|
42
|
+
attrs: { for: "selectControl" },
|
|
43
|
+
parent: myDOM.selectControlContainer,
|
|
44
|
+
});
|
|
45
|
+
|
|
43
46
|
myDOM.selectControl = DOMElem.Create({
|
|
44
47
|
tag: "select",
|
|
45
48
|
attrs: { id: "selectControl" },
|
|
46
49
|
style: { color: "red" },
|
|
47
|
-
|
|
50
|
+
parent: myDOM.selectControlContainer,
|
|
48
51
|
children: animalOption,
|
|
49
52
|
});
|
|
50
53
|
|
|
51
|
-
myDOM.selectControl = DOMElem.Create({
|
|
52
|
-
tag: "label",
|
|
53
|
-
attrs: { for: "selectControl" },
|
|
54
|
-
targetParent: myDOM.selectControlContainer,
|
|
55
|
-
});
|
|
56
|
-
|
|
57
54
|
/* 3. Úgy is haszálhatom, hogy egyből appendolom és azt változónak adom */
|
|
58
55
|
|
|
59
56
|
let plants = ["Fenyő", "Juhar", "Cédrus", "Mahagóni"];
|
|
60
57
|
|
|
61
58
|
myDOM.selectControl = myDOM.selectControl.appendChild(
|
|
62
59
|
DOMElem.Create({
|
|
63
|
-
tag: "
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
60
|
+
tag: "label",
|
|
61
|
+
text: "fák:",
|
|
62
|
+
attrs: { for: "selectControl" },
|
|
63
|
+
parent: myDOM.selectControlContainer,
|
|
67
64
|
})
|
|
68
65
|
);
|
|
69
|
-
|
|
70
66
|
myDOM.selectControl = myDOM.selectControl.appendChild(
|
|
71
67
|
DOMElem.Create({
|
|
72
|
-
tag: "
|
|
73
|
-
attrs: {
|
|
74
|
-
|
|
68
|
+
tag: "select",
|
|
69
|
+
attrs: { id: "selectControl" },
|
|
70
|
+
parent: myDOM.selectControlContainer,
|
|
71
|
+
children: generateOption(plants),
|
|
75
72
|
})
|
|
76
73
|
);
|
|
77
74
|
|
|
@@ -94,7 +91,7 @@
|
|
|
94
91
|
attrs: {
|
|
95
92
|
class: "beginDate-lable",
|
|
96
93
|
},
|
|
97
|
-
|
|
94
|
+
text: "Kezdő dátum: ",
|
|
98
95
|
}),
|
|
99
96
|
DOMElem.Create({
|
|
100
97
|
tag: "input",
|
|
@@ -120,7 +117,7 @@
|
|
|
120
117
|
attrs: {
|
|
121
118
|
class: "endDate-lable",
|
|
122
119
|
},
|
|
123
|
-
|
|
120
|
+
text: "Befejező dátum: ",
|
|
124
121
|
}),
|
|
125
122
|
DOMElem.Create({
|
|
126
123
|
tag: "input",
|
package/test/createDOMElem.html
CHANGED
|
@@ -20,21 +20,35 @@
|
|
|
20
20
|
text: "Hello World!",
|
|
21
21
|
parent: app,
|
|
22
22
|
style: "color: red; background-color: green",
|
|
23
|
-
attrs: { id: "
|
|
23
|
+
attrs: { id: "title1", dataset: { text: "redText" } },
|
|
24
24
|
});
|
|
25
25
|
createDOMElem({
|
|
26
26
|
tag: "h2",
|
|
27
27
|
text: "It's amazing",
|
|
28
28
|
parent: app,
|
|
29
|
-
style: { color: "red",
|
|
30
|
-
attrs:
|
|
29
|
+
style: { color: "red", backgroundColor: "pink" },
|
|
30
|
+
attrs: [
|
|
31
|
+
{
|
|
32
|
+
id: "title2",
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
dataset: [{ text: "redText" }, { bg: "greenBG" }],
|
|
36
|
+
},
|
|
37
|
+
],
|
|
31
38
|
});
|
|
32
39
|
createDOMElem({
|
|
33
40
|
tag: "h3",
|
|
34
41
|
text: "I can write style as I want to",
|
|
35
42
|
parent: app,
|
|
36
|
-
style: ["color: red", "background-color:
|
|
37
|
-
attrs: { id: "
|
|
43
|
+
style: ["color: red", "background-color: blue"],
|
|
44
|
+
attrs: { id: "title3" },
|
|
45
|
+
});
|
|
46
|
+
createDOMElem({
|
|
47
|
+
tag: "h4",
|
|
48
|
+
text: "Awesome",
|
|
49
|
+
parent: app,
|
|
50
|
+
style: [{ color: "red" }, { backgroundColor: "green" }],
|
|
51
|
+
attrs: { id: "title4" },
|
|
38
52
|
});
|
|
39
53
|
|
|
40
54
|
/* creating a select with 2 options and eventHandler */
|