DE
Size: a a a
DE
DE
DE
el.innerHTML = '<div></div>'
DE
DE
DE
DE
/**
* Creates an element
*
* @param {string} tag
* @param {Object} options
*/
function createElement (tag, options) {
const el = document.createElement(tag);
if (options && !(options instanceof Object)) {
throw new TypeError('The second attribute must be an object!')
}
Object.keys(options).forEach((key) => {
el[key.replace(/([A-Z])/g, '-$1').toLowerCase()] = options[key];
});
return el;
}
DE
DE
/**
* Creates an element
*
* @param {string} tag
* @param {Object} options
*/
function createElement (tag, options) {
const el = document.createElement(tag);
if (options && !(options instanceof Object)) {
throw new TypeError('The second attribute must be an object!')
}
Object.keys(options).forEach((key) => {
el[key.replace(/([A-Z])/g, '-$1').toLowerCase()] = options[key];
});
return el;
}
DE
const {
class: className,
data: dataset,
...other,
} = options;
F
А
F
${key}:${style[key]};
А
for(let key in option.style) {
if(option.style.hasOwnProperty(key
) {
el.style.cssText+=${key}:${style[key]};
}
}
А
${key}:${style[key]};