ullamlaboriosam
Version:
Lightweight and intuitive javascript library
13 lines (12 loc) • 483 B
JavaScript
// [INTERNAL USE ONLY]
// Generate a fragment of HTML. This irons out the inconsistences
u.prototype.generate = function (html) {
// Table elements need to be child of <table> for some f***ed up reason
if (/^\s*<t(h|r|d)/.test(html)) {
return u(document.createElement('table')).html(html).children().nodes;
} else if (/^\s*</.test(html)) {
return u(document.createElement('div')).html(html).children().nodes;
} else {
return document.createTextNode(html);
}
};