diff --git a/lib/plates.js b/lib/plates.js index 26cb322..85b8c92 100644 --- a/lib/plates.js +++ b/lib/plates.js @@ -147,7 +147,17 @@ function matchClosing(input, tagname, html) { // separators. So we need to detect these elements based on the tag name. // selfClosing: /^(area|base|br|col|command|embed|hr|img|input|keygen|link|meta|param|source|track|wbr)$/, - + + // + // Boolean Attributes - attributes that require no value + // + booleanAttr: ['allowfullscreen','async','autofocus','autoplay','checked','compact','controls', + 'declare','default','defaultchecked','defaultmuted','defaultselected','defer','disabled', + 'draggable','enabled','formnovalidate','hidden','indeterminate','inert','ismap','itemscope', + 'loop','multiple','muted','nohref','noresize','noshade','novalidate','nowrap','open', + 'pauseonexit','readonly','required','reversed','scoped','seamless','selected','sortable', + 'spellcheck','translate','truespeed','typemustmatch','visible'], + // // ### function hasClass(str, className) // #### @str {String} the class attribute @@ -327,6 +337,13 @@ function matchClosing(input, tagname, html) { } else { newdata = fetch(data, mapping, value, tagbody, key); } + + // + // remove a Boolean attribute if the value evaluates to false + // + if (!newdata && Merge.prototype.booleanAttr.indexOf(key.toLowerCase()) != -1) { + return ''; + } return key + '="' + (newdata || '') + '"'; } else if (!mapping.replace && mapping.attribute === key) {