code: function kwtoattr(html_attrs, merge){
        var k,v;
        var rv = '';
        if (merge) {
         for (k in merge) {
           if (merge.hasOwnProperty(k)) {
             v = merge[k];
             if(html_attrs.hasOwnProperty(k)){
                v = html_attrs[k] + ' ' + v
             }
             html_attrs[k] = v
           }
         }
       }
  
       var booleanAttributes = " hidden novalidate formnovalidate readonly required multiple autofocus disabled selected";
  
         for (k in html_attrs){
            if(!html_attrs.hasOwnProperty(k) || typeof html_attrs[k] !== 'string')
              continue;
  
            if (booleanAttributes.indexOf(" " + k + " ") > -1) {
              if (html_attrs[k]==k || html_attrs[k]=="") //otherwise omit
                rv += k + " ";
            } else {
             rv += k + '= "' + html_attrs[k].replace(/&/g,'&amp;').replace(/"/g,'&quot;') + '" ';
           }
         }
         return rv;
     }
docs: may have an additional merge obj, with more key->value pairs. They are all merged into the referenced html_attrs object, and the function returns a string of the key/values formatted for inclusion and html attributes.