(defn element
"Ensure an element vector is of the form [tag-name attrs content]."
[[tag & content]]
(when-not (or (keyword? tag)
(symbol? tag)
(string? tag))
(throw (ex-info (str tag " is not a valid element name.") {:tag tag :content content})))
(let [[tag id class] (match-tag tag)
tag-attrs (compact-map {:id id :class class})
map-attrs (first content)]
(if (map? map-attrs)
[tag
(merge-with-class tag-attrs map-attrs)
(children (next content))]
[tag
(attributes tag-attrs)
(children content)])))