domelemjs 1.0.12 → 1.1.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/README.md +2 -2
- package/index.js +107 -198
- package/index.min.js +1 -1
- package/index.min.js.map +98 -98
- package/package.json +1 -1
- package/test/DOMElem.html +23 -26
- package/test/createDOMElem.html +19 -9
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,
|
|
@@ -143,39 +25,26 @@ const createDOMElem = ({
|
|
|
143
25
|
/*
|
|
144
26
|
* add all the attributes they want
|
|
145
27
|
*/
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
if (
|
|
152
|
-
|
|
28
|
+
|
|
29
|
+
attrs &&
|
|
30
|
+
Object.keys(attrs).forEach((attr) => {
|
|
31
|
+
if (attr === "checked") {
|
|
32
|
+
elem.checked = attrs[attr];
|
|
33
|
+
} else if (attr === "dataset") {
|
|
34
|
+
makeThatArray(attrs[attr]).map((data) =>
|
|
35
|
+
Object.keys(data).forEach((d) => (elem.dataset[d] = data[d]))
|
|
36
|
+
);
|
|
37
|
+
} else if (attr === "class" || attr === "id") {
|
|
38
|
+
elem.setAttribute(
|
|
39
|
+
attr,
|
|
40
|
+
makeThatArray(attrs[attr])
|
|
41
|
+
.map((a) => noSpecChars(a))
|
|
42
|
+
.join(" ")
|
|
43
|
+
);
|
|
153
44
|
} else {
|
|
154
|
-
|
|
45
|
+
elem.setAttribute(attr, makeThatArray(attrs[attr]).join(" "));
|
|
155
46
|
}
|
|
156
|
-
|
|
157
|
-
for (let d in data) {
|
|
158
|
-
elem.dataset[d] = data[d];
|
|
159
|
-
}
|
|
160
|
-
});
|
|
161
|
-
} else {
|
|
162
|
-
let attribute;
|
|
163
|
-
if (Array.isArray(attrs[attr])) {
|
|
164
|
-
if (attr === "class") {
|
|
165
|
-
attribute = attrs[attr].map((a) => noSpecChars(a)).join(" ");
|
|
166
|
-
} else {
|
|
167
|
-
attribute = attrs[attr].join(" ");
|
|
168
|
-
}
|
|
169
|
-
} else {
|
|
170
|
-
if (attr === "id") {
|
|
171
|
-
attribute = noSpecChars(attrs[attr]);
|
|
172
|
-
} else {
|
|
173
|
-
attribute = attrs[attr];
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
elem.setAttribute(attr, attribute);
|
|
177
|
-
}
|
|
178
|
-
}
|
|
47
|
+
});
|
|
179
48
|
|
|
180
49
|
/*
|
|
181
50
|
* Adding stye is possible as:
|
|
@@ -186,66 +55,41 @@ const createDOMElem = ({
|
|
|
186
55
|
* * or an array with multiple style strings with CSS or JS vesrion, or mixed
|
|
187
56
|
*/
|
|
188
57
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
.split("-")
|
|
207
|
-
.map((ss, i) => {
|
|
208
|
-
return i > 0 ? ss.charAt(0).toUpperCase() + ss.slice(1) : ss;
|
|
209
|
-
})
|
|
210
|
-
.join("");
|
|
211
|
-
elem.style[s] = p;
|
|
212
|
-
});
|
|
213
|
-
}
|
|
58
|
+
style &&
|
|
59
|
+
makeThatArray(style)
|
|
60
|
+
.map((styleElem) => {
|
|
61
|
+
if (typeof styleElem === "object") {
|
|
62
|
+
return Object.keys(styleElem)
|
|
63
|
+
.map((styleTxt) => `${styleTxt}: ${styleElem[styleTxt]}`)
|
|
64
|
+
.join("; ");
|
|
65
|
+
} else {
|
|
66
|
+
return makeThatArray(styleElem).join("; ");
|
|
67
|
+
}
|
|
68
|
+
})
|
|
69
|
+
.join("; ")
|
|
70
|
+
.split(";")
|
|
71
|
+
.forEach((styleTxts) => {
|
|
72
|
+
let [styleTxt, val] = styleTxts.split(":").map((c) => c.trim());
|
|
73
|
+
elem.style[makeCamelCase(styleTxt)] = val;
|
|
74
|
+
});
|
|
214
75
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
childrenArray = [...children];
|
|
221
|
-
}
|
|
222
|
-
childrenArray.map((child) => {
|
|
223
|
-
typeof child != "object"
|
|
224
|
-
? (child = document.createTextNode(child))
|
|
225
|
-
: null;
|
|
226
|
-
elem.appendChild(child);
|
|
76
|
+
children &&
|
|
77
|
+
makeThatArray(children).map((child) => {
|
|
78
|
+
let childElem = child;
|
|
79
|
+
if (typeof child === "object") childElem = createDOMElem(child);
|
|
80
|
+
elem.appendChild(childElem);
|
|
227
81
|
});
|
|
228
|
-
}
|
|
229
82
|
|
|
230
83
|
/*
|
|
231
84
|
* Add the eventListener or more eventListeners it hey comes in array
|
|
232
|
-
*/
|
|
233
|
-
let eventsToAdd = [];
|
|
234
|
-
/*
|
|
235
85
|
* Handle event is an object or an array of object, that schould be conain:
|
|
236
86
|
* event, what will fire the event?
|
|
237
87
|
* and a cb, that is the callback function
|
|
238
88
|
*/
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
eventsToAdd = [...handleEvent];
|
|
242
|
-
} else {
|
|
243
|
-
eventsToAdd.push(handleEvent);
|
|
244
|
-
}
|
|
245
|
-
eventsToAdd.forEach((newEvent) => {
|
|
89
|
+
handleEvent &&
|
|
90
|
+
makeThatArray(handleEvent).forEach((newEvent) => {
|
|
246
91
|
elem.addEventListener(newEvent.event, newEvent.cb);
|
|
247
92
|
});
|
|
248
|
-
}
|
|
249
93
|
|
|
250
94
|
/*
|
|
251
95
|
* Append the created elem to the parent what is given, or add to the body of the Document if not given.
|
|
@@ -275,3 +119,68 @@ const createDOMElem = ({
|
|
|
275
119
|
*/
|
|
276
120
|
return elem;
|
|
277
121
|
};
|
|
122
|
+
|
|
123
|
+
/* object caller of the funcion */
|
|
124
|
+
const DOMElem = {
|
|
125
|
+
Create: createDOMElem,
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
/******************/
|
|
129
|
+
/* HELPER METHODS */
|
|
130
|
+
/******************/
|
|
131
|
+
|
|
132
|
+
/* removing special chars form a string */
|
|
133
|
+
const noSpecChars = (text, lowercase = false) => {
|
|
134
|
+
function replaceAll(string, search, replace) {
|
|
135
|
+
return string.split(search).join(replace);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
let specialChars = {
|
|
139
|
+
é: "e",
|
|
140
|
+
á: "a",
|
|
141
|
+
ó: "o",
|
|
142
|
+
ö: "o",
|
|
143
|
+
ő: "o",
|
|
144
|
+
ú: "u",
|
|
145
|
+
ü: "u",
|
|
146
|
+
ű: "u",
|
|
147
|
+
í: "i",
|
|
148
|
+
É: "E",
|
|
149
|
+
Á: "A",
|
|
150
|
+
Ó: "O",
|
|
151
|
+
Ö: "O",
|
|
152
|
+
Ő: "O",
|
|
153
|
+
Ú: "U",
|
|
154
|
+
Ü: "U",
|
|
155
|
+
Ű: "U",
|
|
156
|
+
Í: "I",
|
|
157
|
+
" ": "-",
|
|
158
|
+
"/": "-",
|
|
159
|
+
":": "-",
|
|
160
|
+
";": "-",
|
|
161
|
+
"=": "-",
|
|
162
|
+
};
|
|
163
|
+
for (let char in specialChars) {
|
|
164
|
+
text = replaceAll(text, char, specialChars[char]);
|
|
165
|
+
}
|
|
166
|
+
return lowercase ? text.toLowerCase() : text;
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
/* check is it is array do nothing, if not maki it array */
|
|
170
|
+
const makeThatArray = (arr) => {
|
|
171
|
+
if (Array.isArray(arr)) {
|
|
172
|
+
return arr;
|
|
173
|
+
} else {
|
|
174
|
+
return [arr];
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
/* removing the "-" symbol form the string adn makind the afterward word to uppercase, that is named as camelCase */
|
|
179
|
+
function makeCamelCase(s) {
|
|
180
|
+
return s
|
|
181
|
+
.split("-")
|
|
182
|
+
.map((ss, i) => {
|
|
183
|
+
return i > 0 ? ss.charAt(0).toUpperCase() + ss.slice(1) : ss;
|
|
184
|
+
})
|
|
185
|
+
.join("");
|
|
186
|
+
}
|
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&&Object.keys(attrs).forEach(attr=>{"checked"===attr?elem.checked=attrs[attr]:"dataset"===attr?makeThatArray(attrs[attr]).map(data=>Object.keys(data).forEach(d=>elem.dataset[d]=data[d])):"class"===attr||"id"===attr?elem.setAttribute(attr,makeThatArray(attrs[attr]).map(a=>noSpecChars(a)).join(" ")):elem.setAttribute(attr,makeThatArray(attrs[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
|
@@ -1,99 +1,99 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": [
|
|
4
|
-
"index.js"
|
|
5
|
-
],
|
|
6
|
-
"names": [
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
"
|
|
65
|
-
"
|
|
66
|
-
"
|
|
67
|
-
"
|
|
68
|
-
"
|
|
69
|
-
"
|
|
70
|
-
"
|
|
71
|
-
"
|
|
72
|
-
"
|
|
73
|
-
"
|
|
74
|
-
"
|
|
75
|
-
"
|
|
76
|
-
"
|
|
77
|
-
"
|
|
78
|
-
"
|
|
79
|
-
"
|
|
80
|
-
"
|
|
81
|
-
"
|
|
82
|
-
"
|
|
83
|
-
"
|
|
84
|
-
"
|
|
85
|
-
"
|
|
86
|
-
"
|
|
87
|
-
"
|
|
88
|
-
"
|
|
89
|
-
"
|
|
90
|
-
"
|
|
91
|
-
"
|
|
92
|
-
"
|
|
93
|
-
"
|
|
94
|
-
"
|
|
95
|
-
"
|
|
96
|
-
],
|
|
97
|
-
"mappings": "AAAA,MAAMA,
|
|
98
|
-
"file": "index.js"
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": [
|
|
4
|
+
"index.js"
|
|
5
|
+
],
|
|
6
|
+
"names": [
|
|
7
|
+
"createDOMElem",
|
|
8
|
+
"tag",
|
|
9
|
+
"content",
|
|
10
|
+
"text",
|
|
11
|
+
"attrs",
|
|
12
|
+
"style",
|
|
13
|
+
"children",
|
|
14
|
+
"parent",
|
|
15
|
+
"handleEvent",
|
|
16
|
+
"elem",
|
|
17
|
+
"document",
|
|
18
|
+
"createElement",
|
|
19
|
+
"innerHTML",
|
|
20
|
+
"textContent",
|
|
21
|
+
"Object",
|
|
22
|
+
"keys",
|
|
23
|
+
"forEach",
|
|
24
|
+
"attr",
|
|
25
|
+
"checked",
|
|
26
|
+
"makeThatArray",
|
|
27
|
+
"map",
|
|
28
|
+
"data",
|
|
29
|
+
"d",
|
|
30
|
+
"dataset",
|
|
31
|
+
"setAttribute",
|
|
32
|
+
"a",
|
|
33
|
+
"noSpecChars",
|
|
34
|
+
"join",
|
|
35
|
+
"styleElem",
|
|
36
|
+
"styleTxt",
|
|
37
|
+
"split",
|
|
38
|
+
"styleTxts",
|
|
39
|
+
"val",
|
|
40
|
+
"c",
|
|
41
|
+
"trim",
|
|
42
|
+
"makeCamelCase",
|
|
43
|
+
"child",
|
|
44
|
+
"childElem",
|
|
45
|
+
"appendChild",
|
|
46
|
+
"newEvent",
|
|
47
|
+
"addEventListener",
|
|
48
|
+
"event",
|
|
49
|
+
"cb",
|
|
50
|
+
"prep",
|
|
51
|
+
"querySelector",
|
|
52
|
+
"filter",
|
|
53
|
+
"pe",
|
|
54
|
+
"DOMElem",
|
|
55
|
+
"Create",
|
|
56
|
+
"lowercase",
|
|
57
|
+
"replaceAll",
|
|
58
|
+
"string",
|
|
59
|
+
"search",
|
|
60
|
+
"replace",
|
|
61
|
+
"specialChars",
|
|
62
|
+
"é",
|
|
63
|
+
"á",
|
|
64
|
+
"ó",
|
|
65
|
+
"ö",
|
|
66
|
+
"ő",
|
|
67
|
+
"ú",
|
|
68
|
+
"ü",
|
|
69
|
+
"ű",
|
|
70
|
+
"í",
|
|
71
|
+
"É",
|
|
72
|
+
"Á",
|
|
73
|
+
"Ó",
|
|
74
|
+
"Ö",
|
|
75
|
+
"Ő",
|
|
76
|
+
"Ú",
|
|
77
|
+
"Ü",
|
|
78
|
+
"Ű",
|
|
79
|
+
"Í",
|
|
80
|
+
" ",
|
|
81
|
+
"/",
|
|
82
|
+
":",
|
|
83
|
+
";",
|
|
84
|
+
"=",
|
|
85
|
+
"char",
|
|
86
|
+
"toLowerCase",
|
|
87
|
+
"arr",
|
|
88
|
+
"Array",
|
|
89
|
+
"isArray",
|
|
90
|
+
"s",
|
|
91
|
+
"ss",
|
|
92
|
+
"i",
|
|
93
|
+
"charAt",
|
|
94
|
+
"toUpperCase",
|
|
95
|
+
"slice"
|
|
96
|
+
],
|
|
97
|
+
"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,KA0GlC,OArGAC,UAAYO,KAAKG,UAAYV,SAI7BC,OAASM,KAAKI,YAAcV,MAM5BC,OACEU,OAAOC,KAAKX,OAAOY,QAASC,OACb,YAATA,KACFR,KAAKS,QAAUd,MAAMa,MACH,YAATA,KACTE,cAAcf,MAAMa,OAAOG,IAAKC,MAC9BP,OAAOC,KAAKM,MAAML,QAASM,GAAOb,KAAKc,QAAQD,GAAKD,KAAKC,KAEzC,UAATL,MAA6B,OAATA,KAC7BR,KAAKe,aACHP,KACAE,cAAcf,MAAMa,OACjBG,IAAKK,GAAMC,YAAYD,IACvBE,KAAK,MAGVlB,KAAKe,aAAaP,KAAME,cAAcf,MAAMa,OAAOU,KAAK,QAa9DtB,OACEc,cAAcd,OACXe,IAAKQ,WACqB,iBAAdA,UACFd,OAAOC,KAAKa,WAChBR,IAAKS,UAAa,GAAGA,aAAaD,UAAUC,aAC5CF,KAAK,MAEDR,cAAcS,WAAWD,KAAK,OAGxCA,KAAK,MACLG,MAAM,KACNd,QAASe,YACR,IAAKF,SAAUG,KAAOD,UAAUD,MAAM,KAAKV,IAAKa,GAAMA,EAAEC,QACxDzB,KAAKJ,MAAM8B,cAAcN,WAAaG,MAG5C1B,UACEa,cAAcb,UAAUc,IAAKgB,QAC3B,IAAIC,UAAYD,MACK,iBAAVA,QAAoBC,UAAYrC,cAAcoC,QACzD3B,KAAK6B,YAAYD,aASrB7B,aACEW,cAAcX,aAAaQ,QAASuB,WAClC9B,KAAK+B,iBAAiBD,SAASE,MAAOF,SAASG,MAY/CnC,OACoB,iBAAXA,SACTA,OAAS,CAAC,IAAK,KACZa,IAAKuB,MACGjC,SAASkC,cAAcD,KAAOpC,SAEtCsC,OAAQC,IACO,OAAPA,IACN,IAEFvC,OAASG,SAASkC,cAAc,QAEvCrC,OAAO+B,YAAY7B,MAKZA,MAIHsC,QAAU,CACdC,OAAQhD,eAQJ0B,YAAc,CAACvB,KAAM8C,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,aACfnD,KAAO+C,WAAW/C,KAAM2E,KAAMxB,aAAawB,OAE7C,OAAO7B,UAAY9C,KAAK4E,cAAgB5E,MAIpCgB,cAAiB6D,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",
|
|
98
|
+
"file": "index.js"
|
|
99
99
|
}
|
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,31 @@
|
|
|
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
|
+
id: "title2",
|
|
32
|
+
dataset: [{ text: "redText" }, { bg: "greenBG" }],
|
|
33
|
+
},
|
|
31
34
|
});
|
|
32
35
|
createDOMElem({
|
|
33
36
|
tag: "h3",
|
|
34
37
|
text: "I can write style as I want to",
|
|
35
38
|
parent: app,
|
|
36
|
-
style: ["color: red", "background-color:
|
|
37
|
-
attrs: { id: "
|
|
39
|
+
style: ["color: red", "background-color: blue"],
|
|
40
|
+
attrs: { id: "title3" },
|
|
41
|
+
});
|
|
42
|
+
createDOMElem({
|
|
43
|
+
tag: "h4",
|
|
44
|
+
text: "Awesome",
|
|
45
|
+
parent: app,
|
|
46
|
+
style: [{ color: "red" }, { backgroundColor: "green" }],
|
|
47
|
+
attrs: { id: "title4" },
|
|
38
48
|
});
|
|
39
49
|
|
|
40
50
|
/* creating a select with 2 options and eventHandler */
|
|
@@ -45,13 +55,13 @@
|
|
|
45
55
|
children: [
|
|
46
56
|
{
|
|
47
57
|
tag: "option",
|
|
48
|
-
|
|
49
|
-
|
|
58
|
+
text: "foo",
|
|
59
|
+
attrs: { value: "foo" },
|
|
50
60
|
},
|
|
51
61
|
{
|
|
52
62
|
tag: "option",
|
|
53
|
-
|
|
54
|
-
|
|
63
|
+
text: "bar",
|
|
64
|
+
attrs: { value: "bar" },
|
|
55
65
|
},
|
|
56
66
|
],
|
|
57
67
|
handleEvent: {
|