Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion lib/plates.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down