Permalink
Browse files

Don't put in self-closing tags on anything.

  • Loading branch information...
1 parent 5820bcc commit 691749620de83fbee2ce1f7803c777af376360c5 @danielmorrison danielmorrison committed Apr 4, 2009
Showing with 13 additions and 25 deletions.
  1. +13 −25 lib/html5.rb
View
@@ -16,32 +16,20 @@ def javascript_src_tag_with_empty_type(source, options)
def stylesheet_tag(source, options)
tag("link", { "rel" => "stylesheet", "media" => "screen", "href" => html_escape(path_to_stylesheet(source)) }.merge(options), ::SKIP_SELF_CLOSE_TAGS, false)
end
-
- def image_tag(source, options = {})
- options.symbolize_keys!
-
- options[:src] = path_to_image(source)
- options[:alt] ||= File.basename(options[:src], '.*').split('.').first.to_s.capitalize
- if size = options.delete(:size)
- options[:width], options[:height] = size.split("x") if size =~ %r{^\d+x\d+$}
- end
+end
- if mouseover = options.delete(:mouseover)
- options[:onmouseover] = "this.src='#{image_path(mouseover)}'"
- options[:onmouseout] = "this.src='#{image_path(options[:src])}'"
- end
-
- tag("img", options, ::SKIP_SELF_CLOSE_TAGS)
- end
+module ActionView::Helpers::TagHelper
+ # When served as text/html, tags do not need to be self-closed.
+ # http://www.whatwg.org/specs/web-apps/current-work/#void-elements
+ VOID_ELEMENTS = %w(base command link meta hr br img embed param area col input source)
+
+ def tag_with_skip_self_closing(name, options = nil, open = false, escape = true)
+ open = true if VOID_ELEMENTS.include?(name.to_s) && ::SKIP_SELF_CLOSE_TAGS
- def auto_discovery_link_tag(type = :rss, url_options = {}, tag_options = {})
- tag(
- "link",
- {"rel" => tag_options[:rel] || "alternate",
- "type" => tag_options[:type] || Mime::Type.lookup_by_extension(type.to_s).to_s,
- "title" => tag_options[:title] || type.to_s.upcase,
- "href" => url_options.is_a?(Hash) ? url_for(url_options.merge(:only_path => false)) : url_options}, ::SKIP_SELF_CLOSE_TAGS
- )
+ tag_without_skip_self_closing(name, options, open, escape)
end
-end
+ alias_method_chain :tag, :skip_self_closing
+end
+
+

0 comments on commit 6917496

Please sign in to comment.