Skip to content

Commit

Permalink
resolves #2046 pass through preload attribute to video tag (PR #2103)
Browse files Browse the repository at this point in the history
  • Loading branch information
mojavelinux committed Mar 31, 2017
1 parent 76dd3f2 commit 966137f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions lib/asciidoctor/converter/html5.rb
Expand Up @@ -998,13 +998,14 @@ def video node
</div>
</div>)
else
poster_attribute = %(#{poster = node.attr 'poster'}).empty? ? nil : %( poster="#{node.media_uri poster}")
poster_attribute = (val = node.attr 'poster', nil, false).nil_or_empty? ? nil : %( poster="#{node.media_uri val}")
preload_attribute = (val = node.attr 'preload', nil, false).nil_or_empty? ? nil : %( preload="#{val}")
start_t = node.attr 'start', nil, false
end_t = node.attr 'end', nil, false
time_anchor = (start_t || end_t) ? %(#t=#{start_t}#{end_t ? ',' : nil}#{end_t}) : nil
%(<div#{id_attribute}#{class_attribute}>#{title_element}
<div class="content">
<video src="#{node.media_uri(node.attr 'target')}#{time_anchor}"#{width_attribute}#{height_attribute}#{poster_attribute}#{(node.option? 'autoplay') ? (append_boolean_attribute 'autoplay', xml) : nil}#{(node.option? 'nocontrols') ? nil : (append_boolean_attribute 'controls', xml)}#{(node.option? 'loop') ? (append_boolean_attribute 'loop', xml) : nil}>
<video src="#{node.media_uri(node.attr 'target')}#{time_anchor}"#{width_attribute}#{height_attribute}#{poster_attribute}#{(node.option? 'autoplay') ? (append_boolean_attribute 'autoplay', xml) : nil}#{(node.option? 'nocontrols') ? nil : (append_boolean_attribute 'controls', xml)}#{(node.option? 'loop') ? (append_boolean_attribute 'loop', xml) : nil}#{preload_attribute}>
Your browser does not support the video tag.
</video>
</div>
Expand Down
3 changes: 2 additions & 1 deletion test/blocks_test.rb
Expand Up @@ -1962,14 +1962,15 @@ def names

test 'video macro should honor all options' do
input = <<-EOS
video::cats-vs-dogs.avi[options="autoplay,nocontrols,loop"]
video::cats-vs-dogs.avi[options="autoplay,nocontrols,loop",preload="metadata"]
EOS

output = render_embedded_string input
assert_css 'video', output, 1
assert_css 'video[autoplay]', output, 1
assert_css 'video:not([controls])', output, 1
assert_css 'video[loop]', output, 1
assert_css 'video[preload=metadata]', output, 1
end

test 'video macro should add time range anchor with start time if start attribute is set' do
Expand Down

0 comments on commit 966137f

Please sign in to comment.