OverviewFilesCommitsIssuesDocsReleasesPeers

apds / lib / h.js

12 lines · javascript ref:
// hscrpt by Dominic Tarr https://github.com/dominictarr/hscrpt/blob/master/LICENSE
export function h (tag, attrs, content) {
  if(Array.isArray(attrs)) content = attrs, attrs = {}
  var el = document.createElement(tag)
  for(var k in attrs) el[k] = attrs[k]
  if(content) content.forEach(function (e) {
    if(e) el.appendChild('string' == typeof e ? document.createTextNode(e) : e)
  })
  return el
}