Permalink
Browse files

sensible handling of boolean HTML tags

  • Loading branch information...
1 parent b3946c6 commit 999c418e3c096d2007d18c0a118390bd07d40eb0 @MatmaRex MatmaRex committed May 13, 2011
Showing with 14 additions and 0 deletions.
  1. +7 −0 lib/markaby/builder.rb
  2. +7 −0 lib/markaby/tags.rb
@@ -178,6 +178,13 @@ def tag!(tag, *args, &block)
raise InvalidXhtmlError, "id `#{ele_id}' already used (id's must be unique)."
end
end
+ if AttrsBoolean.include? atname
+ if v
+ attrs[k] = atname.to_s
+ else
+ attrs.delete k
+ end
+ end
end
end
end
View
@@ -19,6 +19,13 @@ module Markaby
AttrHAlign = [:align, :char, :charoff]
AttrVAlign = [:valign]
Attrs = AttrCore + AttrI18n + AttrEvents
+
+ AttrsBoolean = [
+ :checked, :disabled, :multiple, :readonly, :selected, # standard forms
+ :autofocus, :required, :novalidate, :formnovalidate, # HTML5 forms
+ :defer, :ismap, # <script defer>, <img ismap>
+ :compact, :declare, :noresize, :noshade, :nowrap # deprecated or unused
+ ]
# All the tags and attributes from XHTML 1.0 Strict
class XHTMLStrict

0 comments on commit 999c418

Please sign in to comment.