Initial Commit
This commit is contained in:
30
js/dom.js
Normal file
30
js/dom.js
Normal file
@@ -0,0 +1,30 @@
|
||||
((global) => {
|
||||
|
||||
function createElement(tagName, attributes, text) {
|
||||
var element = document.createElement(tagName);
|
||||
var attrs = attributes || {};
|
||||
var keys = Object.keys(attrs);
|
||||
|
||||
for (var i = 0; i < keys.length; i += 1) {
|
||||
element.setAttribute(keys[i], attrs[keys[i]]);
|
||||
}
|
||||
|
||||
if (text !== undefined && text !== null) {
|
||||
element.textContent = text;
|
||||
}
|
||||
|
||||
return element;
|
||||
}
|
||||
|
||||
function appendChildren(parent, children) {
|
||||
for (var i = 0; i < children.length; i += 1) {
|
||||
parent.appendChild(children[i]);
|
||||
}
|
||||
}
|
||||
|
||||
global.Y2KDom = {
|
||||
createElement: createElement,
|
||||
appendChildren: appendChildren
|
||||
};
|
||||
|
||||
})(window);
|
||||
Reference in New Issue
Block a user