//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// HERE BEGINETH THE SCRIPT
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

(function(global) {
    "use strict";
    var dom = {};
    var tags = [
        "div", "p", "table", "tr", "td", "th", "tbody", "thead", "tfoot", "span", "ul", "ol", "li",
        "a", "select", "option", "input", "button", "h1", "h2", "h3", "h4", "textarea", "label"
    ];

    // helper functions
    function mkArr(obj) {
        return (!!obj ? (Array.isArray(obj) ? obj : [obj]) : []);
    }

    function cfgElem(elem, attrs) {
        var prop;
        for (prop in attrs) {
            if (attrs.hasOwnProperty(prop)) {
                if (prop === "className" || prop === "innerHTML" || prop === "name" || prop === "title") {
                    elem[prop] = attrs[prop];
                } else {
                    elem.setAttribute(prop, attrs[prop]);
                }
            }
        }
        return elem;
    }

    function mkChildren(elem, children) {
        children.forEach(function(child) {
            if (typeof child === "string") {
                elem.appendChild(document.createTextNode(child));
            } else {
                elem.appendChild(child);
            }
        });
        return elem;
    }

    // helper
    // naive shallow mixin function. good enough for now
    function merge(dest) {
        var args = Array.prototype.slice.call(arguments, 1);

        args.forEach(function(obj) {
            var prop;
            for (prop in obj) {
                if (obj.hasOwnProperty(prop)) {
                    dest[prop] = obj[prop];
                }
            }
        });

        return dest;
    }

    // the meaty part:
    dom.el = function(tag, cfg) {
        cfg = cfg || {};
        return function(attrs, children) {
            var elem = (typeof tag === "string" ? document.createElement(tag) : tag);

            // sanity
            if (Array.isArray(attrs) || typeof attrs === "string" || attrs instanceof HTMLElement) {
                children = mkArr(attrs);
                attrs = cfg;
            } else {
                children = mkArr(children);
                attrs = merge({}, cfg, attrs);
            }

            return mkChildren(cfgElem(elem, attrs), children);
        };
    };

    dom.addAll = function(ctx) {
        ctx = ctx || global;
        tags.forEach(function(tag) {
            ctx[tag] = dom.el(tag);
        });
        return ctx;
    };

    dom.addAll(dom);

    global.dom = dom;

}(this));




@@ -1711,17 +1711,16 @@
     %7D);%0A
-%0A
         
@@ -1735,24 +1735,145 @@
 est;%0A    %7D%0A%0A
+    function isElem(obj) %7B%0A        return obj instanceof HTMLElement %7C%7C obj.nodeType === 1 %7C%7C obj.nodeType === 3;%0A    %7D%0A%0A
     // the m
@@ -2167,36 +2167,21 @@
  %7C%7C 
-attrs instanceof HTMLElement
+isElem(attrs)
 ) %7B%0A
@@ -2372,25 +2372,24 @@
           %7D%0A
-%0A
             
@@ -2624,33 +2624,32 @@
 urn ctx;%0A    %7D;%0A
-%0A
     dom.addAll(d

test for HTMLElement or duck-type