JSFiddle - React, Tailwind, and code Playground
JavaScript
function html(elem, html) {
elem = elem || document.documentElement;
html = html || '';
// 읽기전용 태그는 IE만 존재한다.
if (window.attachEvent) {
var nodeName = elem.nodeName && elem.nodeName.toLowerCase();
// 읽기 전용 태그 모음
var readOnlys = {
'col': [3, '<table><colgroup>', '</colgroup></table>'],
'colgroup': [2, '<table>', '</table>'],
'head': [2, '<html>', '</html>'],
'title': [2, '<head>', '</head>'],
'tr': [3, '<table><tbody>', '</tbody></table>'],
'tbody': [2, '<table>', '</table>'],
'tfoot': [2, '<table>', '</table>'],
'thead': [2, '<table>', '</table>'],
'table': [1, '<table>', '</table>']
};
var mapEntry = readOnlys[nodeName];
if (mapEntry) {
var con = document.createElement('div');
con.innerHTML = mapEntry[1] + html + mapEntry[2];
while (mapEntry[0]--) con = con.firstChild;
if (elem.hasAttributes()) {
var attrs = elem.attributes;
for (var i = 0, length = attrs.length; i < length; i++) {
attr(con, attrs[i].name, attr(elem, attrs[i].name));
}
}
elem.parentNode.replaceChild(con, elem);
}
else {
elem.innerHTML = html;
}
}
else {
elem.innerHTML = html;
}
}
function attr(elem, n, val) {
elem = elem || document.documentElement;
n = n || '';
val = val || '';
n = { 'for': 'htmlFor', 'class': 'className'}[n] || n;
if (val) {
elem[n] = val;
// set Attribute
if (elem.setAttribute) {
//elem.setAttribute(n, val);
}
}
return...