mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Allow callers to remove nopush
This commit is contained in:
parent
033ac18590
commit
0b65e23978
2 changed files with 17 additions and 2 deletions
|
@ -87,10 +87,15 @@ module ActionView
|
|||
options = sources.extract_options!.stringify_keys
|
||||
path_options = options.extract!("protocol", "extname", "host", "skip_pipeline").symbolize_keys
|
||||
preload_links = []
|
||||
nopush = options["nopush"].nil? ? true : options.delete("nopush")
|
||||
|
||||
sources_tags = sources.uniq.map { |source|
|
||||
href = path_to_javascript(source, path_options)
|
||||
preload_links << "<#{href}>; rel=preload; as=script; nopush" unless options["defer"]
|
||||
unless options["defer"]
|
||||
preload_link = "<#{href}>; rel=preload; as=script"
|
||||
preload_link += "; nopush" if nopush
|
||||
preload_links << preload_link
|
||||
end
|
||||
tag_options = {
|
||||
"src" => href
|
||||
}.merge!(options)
|
||||
|
@ -137,10 +142,13 @@ module ActionView
|
|||
options = sources.extract_options!.stringify_keys
|
||||
path_options = options.extract!("protocol", "host", "skip_pipeline").symbolize_keys
|
||||
preload_links = []
|
||||
nopush = options["nopush"].nil? ? true : options.delete("nopush")
|
||||
|
||||
sources_tags = sources.uniq.map { |source|
|
||||
href = path_to_stylesheet(source, path_options)
|
||||
preload_links << "<#{href}>; rel=preload; as=style; nopush"
|
||||
preload_link = "<#{href}>; rel=preload; as=style"
|
||||
preload_link += "; nopush" if nopush
|
||||
preload_links << preload_link
|
||||
tag_options = {
|
||||
"rel" => "stylesheet",
|
||||
"media" => "screen",
|
||||
|
|
|
@ -522,6 +522,13 @@ class AssetTagHelperTest < ActionView::TestCase
|
|||
assert_equal "", @response.headers["Link"]
|
||||
end
|
||||
|
||||
def test_should_allow_caller_to_remove_nopush
|
||||
stylesheet_link_tag("http://example.com/style.css", nopush: false)
|
||||
javascript_include_tag("http://example.com/all.js", nopush: false)
|
||||
expected = "<http://example.com/style.css>; rel=preload; as=style,<http://example.com/all.js>; rel=preload; as=script"
|
||||
assert_equal expected, @response.headers["Link"]
|
||||
end
|
||||
|
||||
def test_image_path
|
||||
ImagePathToTag.each { |method, tag| assert_dom_equal(tag, eval(method)) }
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue