actionview 6.1.0 → 6.1.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of actionview might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 66b9ba4747ae5973f8f784343f64e7201d2bbf8299cb9b9dc2ed7869db55cbc6
4
- data.tar.gz: da671bc8666ecd9386fa75a7639c837492df9b0d5b81c9f2a66114a522d6dec9
3
+ metadata.gz: a164a5f7ce09e84dfab86b45a2df631dc782f50fc22c0cbb92f967c95808de63
4
+ data.tar.gz: 9dd5e8614c436054ebb785df67171b16deb22bb8be3518d57ee8486613919d86
5
5
  SHA512:
6
- metadata.gz: 409ff7a86026884f20e3fbf1eb0560fc990328369c15e90500f27dc8336020edc59acfb3b8da61806c7eac62ae501c1c5f176c4dc7da641f3da338bcfb2cc6f5
7
- data.tar.gz: 961932d31d4e46c9674a9ea3229db468dfd922c1b79c9f23403b928763f1a8798848dae25554f09255965968109e7557953b4c3a7d6573e142061a3fc3e360c7
6
+ metadata.gz: 3502d7dd7b2407ce4634afadcd61b2d654f248d91bf85d9f43bd6b1ad150fdd84a45b6f009a04d899be293d123be503a7e497b761c10a576bea6c9248140f599
7
+ data.tar.gz: 3b0695d10e6939424bf14a8cbcea85f6628de02d0a4de37266213883604be8a95daf65eb435cf32260dae4d8b8ad562af7c37a3b426a2589fd305056ec381361
@@ -1,3 +1,29 @@
1
+ ## Rails 6.1.1 (January 07, 2021) ##
2
+
3
+ * Fix lazy translation in partial with block.
4
+
5
+ *Marek Kasztelnik*
6
+
7
+ * Avoid extra `SELECT COUNT` queries when rendering Active Record collections.
8
+
9
+ *aar0nr*
10
+
11
+ * Link preloading keep integrity hashes in the header.
12
+
13
+ *Étienne Barrié*
14
+
15
+ * Add `config.action_view.preload_links_header` to allow disabling of
16
+ the `Link` header being added by default when using `stylesheet_link_tag`
17
+ and `javascript_include_tag`.
18
+
19
+ *Andrew White*
20
+
21
+ * The `translate` helper now resolves `default` values when a `nil` key is
22
+ specified, instead of always returning `nil`.
23
+
24
+ *Jonathan Hefner*
25
+
26
+
1
27
  ## Rails 6.1.0 (December 09, 2020) ##
2
28
 
3
29
  * SanitizeHelper.sanitized_allowed_attributes and SanitizeHelper.sanitized_allowed_tags
@@ -241,12 +241,12 @@ module ActionView #:nodoc:
241
241
  end
242
242
 
243
243
  def _run(method, template, locals, buffer, add_to_stack: true, &block)
244
- _old_output_buffer, _old_template = @output_buffer, @current_template
244
+ _old_output_buffer, _old_virtual_path, _old_template = @output_buffer, @virtual_path, @current_template
245
245
  @current_template = template if add_to_stack
246
246
  @output_buffer = buffer
247
247
  public_send(method, locals, buffer, &block)
248
248
  ensure
249
- @output_buffer, @current_template = _old_output_buffer, _old_template
249
+ @output_buffer, @virtual_path, @current_template = _old_output_buffer, _old_virtual_path, _old_template
250
250
  end
251
251
 
252
252
  def compiled_method_container
@@ -18,6 +18,7 @@ module ActionView
18
18
  def _prepare_context
19
19
  @view_flow = OutputFlow.new
20
20
  @output_buffer = nil
21
+ @virtual_path = nil
21
22
  end
22
23
 
23
24
  # Encapsulates the interaction with the view flow so it
@@ -9,7 +9,7 @@ module ActionView
9
9
  module VERSION
10
10
  MAJOR = 6
11
11
  MINOR = 1
12
- TINY = 0
12
+ TINY = 1
13
13
  PRE = nil
14
14
 
15
15
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
@@ -23,6 +23,8 @@ module ActionView
23
23
  include AssetUrlHelper
24
24
  include TagHelper
25
25
 
26
+ mattr_accessor :preload_links_header
27
+
26
28
  # Returns an HTML script tag for each of the +sources+ provided.
27
29
  #
28
30
  # Sources may be paths to JavaScript files. Relative paths are assumed to be relative
@@ -90,12 +92,14 @@ module ActionView
90
92
  nopush = options["nopush"].nil? ? true : options.delete("nopush")
91
93
  crossorigin = options.delete("crossorigin")
92
94
  crossorigin = "anonymous" if crossorigin == true
95
+ integrity = options["integrity"]
93
96
 
94
97
  sources_tags = sources.uniq.map { |source|
95
98
  href = path_to_javascript(source, path_options)
96
- unless options["defer"]
99
+ if preload_links_header && !options["defer"]
97
100
  preload_link = "<#{href}>; rel=preload; as=script"
98
101
  preload_link += "; crossorigin=#{crossorigin}" unless crossorigin.nil?
102
+ preload_link += "; integrity=#{integrity}" unless integrity.nil?
99
103
  preload_link += "; nopush" if nopush
100
104
  preload_links << preload_link
101
105
  end
@@ -109,7 +113,9 @@ module ActionView
109
113
  content_tag("script", "", tag_options)
110
114
  }.join("\n").html_safe
111
115
 
112
- send_preload_links_header(preload_links)
116
+ if preload_links_header
117
+ send_preload_links_header(preload_links)
118
+ end
113
119
 
114
120
  sources_tags
115
121
  end
@@ -149,13 +155,17 @@ module ActionView
149
155
  crossorigin = options.delete("crossorigin")
150
156
  crossorigin = "anonymous" if crossorigin == true
151
157
  nopush = options["nopush"].nil? ? true : options.delete("nopush")
158
+ integrity = options["integrity"]
152
159
 
153
160
  sources_tags = sources.uniq.map { |source|
154
161
  href = path_to_stylesheet(source, path_options)
155
- preload_link = "<#{href}>; rel=preload; as=style"
156
- preload_link += "; crossorigin=#{crossorigin}" unless crossorigin.nil?
157
- preload_link += "; nopush" if nopush
158
- preload_links << preload_link
162
+ if preload_links_header
163
+ preload_link = "<#{href}>; rel=preload; as=style"
164
+ preload_link += "; crossorigin=#{crossorigin}" unless crossorigin.nil?
165
+ preload_link += "; integrity=#{integrity}" unless integrity.nil?
166
+ preload_link += "; nopush" if nopush
167
+ preload_links << preload_link
168
+ end
159
169
  tag_options = {
160
170
  "rel" => "stylesheet",
161
171
  "media" => "screen",
@@ -165,7 +175,9 @@ module ActionView
165
175
  tag(:link, tag_options)
166
176
  }.join("\n").html_safe
167
177
 
168
- send_preload_links_header(preload_links)
178
+ if preload_links_header
179
+ send_preload_links_header(preload_links)
180
+ end
169
181
 
170
182
  sources_tags
171
183
  end
@@ -256,6 +268,7 @@ module ActionView
256
268
  # * <tt>:as</tt> - Override the auto-generated value for as attribute, calculated using +source+ extension and mime type.
257
269
  # * <tt>:crossorigin</tt> - Specify the crossorigin attribute, required to load cross-origin resources.
258
270
  # * <tt>:nopush</tt> - Specify if the use of server push is not desired for the resource. Defaults to +false+.
271
+ # * <tt>:integrity</tt> - Specify the integrity attribute.
259
272
  #
260
273
  # ==== Examples
261
274
  #
@@ -287,6 +300,7 @@ module ActionView
287
300
  as_type = options.delete(:as) || resolve_link_as(extname, mime_type)
288
301
  crossorigin = options.delete(:crossorigin)
289
302
  crossorigin = "anonymous" if crossorigin == true || (crossorigin.blank? && as_type == "font")
303
+ integrity = options[:integrity]
290
304
  nopush = options.delete(:nopush) || false
291
305
 
292
306
  link_tag = tag.link(**{
@@ -300,6 +314,7 @@ module ActionView
300
314
  preload_link = "<#{href}>; rel=preload; as=#{as_type}"
301
315
  preload_link += "; type=#{mime_type}" if mime_type
302
316
  preload_link += "; crossorigin=#{crossorigin}" if crossorigin
317
+ preload_link += "; integrity=#{integrity}" if integrity
303
318
  preload_link += "; nopush" if nopush
304
319
 
305
320
  send_preload_links_header([preload_link])
@@ -186,8 +186,7 @@ module ActionView
186
186
  # get the authenticity token from the <tt>meta</tt> tag, so embedding is
187
187
  # unnecessary unless you support browsers without JavaScript.
188
188
  # * <tt>:remote</tt> - If set to true, will allow the Unobtrusive
189
- # JavaScript drivers to control the submit behavior. By default this
190
- # behavior is an ajax submit.
189
+ # JavaScript drivers to control the submit behavior.
191
190
  # * <tt>:enforce_utf8</tt> - If set to false, a hidden input with name
192
191
  # utf8 is not output.
193
192
  # * <tt>:html</tt> - Optional HTML attributes for the form tag.
@@ -323,10 +322,8 @@ module ActionView
323
322
  # remote: true
324
323
  #
325
324
  # in the options hash creates a form that will allow the unobtrusive JavaScript drivers to modify its
326
- # behavior. The expected default behavior is an XMLHttpRequest in the background instead of the regular
327
- # POST arrangement, but ultimately the behavior is the choice of the JavaScript driver implementor.
328
- # Even though it's using JavaScript to serialize the form elements, the form submission will work just like
329
- # a regular submission as viewed by the receiving side (all elements available in <tt>params</tt>).
325
+ # behavior. The form submission will work just like a regular submission as viewed by the receiving
326
+ # side (all elements available in <tt>params</tt>).
330
327
  #
331
328
  # Example:
332
329
  #
@@ -536,11 +533,6 @@ module ActionView
536
533
  # accessible as <tt>params[:title]</tt> and <tt>params[:post][:title]</tt>
537
534
  # respectively.
538
535
  #
539
- # By default +form_with+ attaches the <tt>data-remote</tt> attribute
540
- # submitting the form via an XMLHTTPRequest in the background if an
541
- # Unobtrusive JavaScript driver, like rails-ujs, is used. See the
542
- # <tt>:local</tt> option for more.
543
- #
544
536
  # For ease of comparison the examples above left out the submit button,
545
537
  # as well as the auto generated hidden fields that enable UTF-8 support
546
538
  # and adds an authenticity token needed for cross site request forgery
@@ -612,8 +604,10 @@ module ActionView
612
604
  # This is helpful when fragment-caching the form. Remote forms
613
605
  # get the authenticity token from the <tt>meta</tt> tag, so embedding is
614
606
  # unnecessary unless you support browsers without JavaScript.
615
- # * <tt>:local</tt> - By default form submits are remote and unobtrusive XHRs.
616
- # Disable remote submits with <tt>local: true</tt>.
607
+ # * <tt>:local</tt> - By default form submits via typical HTTP requests.
608
+ # Enable remote and unobtrusive XHRs submits with <tt>local: false</tt>.
609
+ # Remote forms may be enabled by default by setting
610
+ # <tt>config.action_view.form_with_generates_remote_forms = true</tt>.
617
611
  # * <tt>:skip_enforcing_utf8</tt> - If set to true, a hidden input with name
618
612
  # utf8 is not output.
619
613
  # * <tt>:builder</tt> - Override the object used to build the form.
@@ -69,7 +69,7 @@ module ActionView
69
69
  #
70
70
  def translate(key, **options)
71
71
  return key.map { |k| translate(k, **options) } if key.is_a?(Array)
72
- key = key.to_s unless key.is_a?(Symbol)
72
+ key = key&.to_s unless key.is_a?(Symbol)
73
73
 
74
74
  alternatives = if options.key?(:default)
75
75
  options[:default].is_a?(Array) ? options.delete(:default).compact : [options.delete(:default)]
@@ -78,13 +78,12 @@ module ActionView
78
78
  options[:raise] = true if options[:raise].nil? && ActionView::Base.raise_on_missing_translations
79
79
  default = MISSING_TRANSLATION
80
80
 
81
- translation = while key
81
+ translation = while key || alternatives.present?
82
82
  if alternatives.blank? && !options[:raise].nil?
83
83
  default = NO_DEFAULT # let I18n handle missing translation
84
84
  end
85
85
 
86
86
  key = scope_key_by_partial(key)
87
- first_key ||= key
88
87
 
89
88
  if html_safe_translation_key?(key)
90
89
  html_safe_options ||= html_escape_translation_options(options)
@@ -97,10 +96,11 @@ module ActionView
97
96
 
98
97
  break alternatives.first if alternatives.present? && !alternatives.first.is_a?(Symbol)
99
98
 
99
+ first_key ||= key
100
100
  key = alternatives&.shift
101
101
  end
102
102
 
103
- if key.nil?
103
+ if key.nil? && !first_key.nil?
104
104
  translation = missing_translation(first_key, options)
105
105
  key = first_key
106
106
  end
@@ -130,11 +130,11 @@ module ActionView
130
130
  end
131
131
 
132
132
  def scope_key_by_partial(key)
133
- if key.start_with?(".")
134
- if @current_template&.virtual_path
133
+ if key&.start_with?(".")
134
+ if @virtual_path
135
135
  @_scope_key_by_partial_cache ||= {}
136
- @_scope_key_by_partial_cache[@current_template.virtual_path] ||= @current_template.virtual_path.gsub(%r{/_?}, ".")
137
- "#{@_scope_key_by_partial_cache[@current_template.virtual_path]}#{key}"
136
+ @_scope_key_by_partial_cache[@virtual_path] ||= @virtual_path.gsub(%r{/_?}, ".")
137
+ "#{@_scope_key_by_partial_cache[@virtual_path]}#{key}"
138
138
  else
139
139
  raise "Cannot use t(#{key.inspect}) shortcut because path is not available"
140
140
  end
@@ -37,6 +37,10 @@ module ActionView
37
37
  end
38
38
  end
39
39
 
40
+ config.after_initialize do |app|
41
+ ActionView::Helpers::AssetTagHelper.preload_links_header = app.config.action_view.delete(:preload_links_header)
42
+ end
43
+
40
44
  config.after_initialize do |app|
41
45
  ActiveSupport.on_load(:action_view) do
42
46
  app.config.action_view.each do |k, v|
@@ -47,6 +47,10 @@ module ActionView
47
47
  def size
48
48
  @collection.size
49
49
  end
50
+
51
+ def length
52
+ @collection.respond_to?(:length) ? @collection.length : size
53
+ end
50
54
  end
51
55
 
52
56
  class SameCollectionIterator < CollectionIterator # :nodoc:
@@ -144,7 +148,7 @@ module ActionView
144
148
  "render_collection.action_view",
145
149
  identifier: identifier,
146
150
  layout: layout && layout.virtual_path,
147
- count: collection.size
151
+ count: collection.length
148
152
  ) do |payload|
149
153
  spacer = if @options.key?(:spacer_template)
150
154
  spacer_template = find_template(@options[:spacer_template], @locals.keys)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: actionview
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.1.0
4
+ version: 6.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Heinemeier Hansson
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-12-09 00:00:00.000000000 Z
11
+ date: 2021-01-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 6.1.0
19
+ version: 6.1.1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 6.1.0
26
+ version: 6.1.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: builder
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -92,28 +92,28 @@ dependencies:
92
92
  requirements:
93
93
  - - '='
94
94
  - !ruby/object:Gem::Version
95
- version: 6.1.0
95
+ version: 6.1.1
96
96
  type: :development
97
97
  prerelease: false
98
98
  version_requirements: !ruby/object:Gem::Requirement
99
99
  requirements:
100
100
  - - '='
101
101
  - !ruby/object:Gem::Version
102
- version: 6.1.0
102
+ version: 6.1.1
103
103
  - !ruby/object:Gem::Dependency
104
104
  name: activemodel
105
105
  requirement: !ruby/object:Gem::Requirement
106
106
  requirements:
107
107
  - - '='
108
108
  - !ruby/object:Gem::Version
109
- version: 6.1.0
109
+ version: 6.1.1
110
110
  type: :development
111
111
  prerelease: false
112
112
  version_requirements: !ruby/object:Gem::Requirement
113
113
  requirements:
114
114
  - - '='
115
115
  - !ruby/object:Gem::Version
116
- version: 6.1.0
116
+ version: 6.1.1
117
117
  description: Simple, battle-tested conventions and helpers for building web pages.
118
118
  email: david@loudthinking.com
119
119
  executables: []
@@ -239,11 +239,11 @@ licenses:
239
239
  - MIT
240
240
  metadata:
241
241
  bug_tracker_uri: https://github.com/rails/rails/issues
242
- changelog_uri: https://github.com/rails/rails/blob/v6.1.0/actionview/CHANGELOG.md
243
- documentation_uri: https://api.rubyonrails.org/v6.1.0/
242
+ changelog_uri: https://github.com/rails/rails/blob/v6.1.1/actionview/CHANGELOG.md
243
+ documentation_uri: https://api.rubyonrails.org/v6.1.1/
244
244
  mailing_list_uri: https://discuss.rubyonrails.org/c/rubyonrails-talk
245
- source_code_uri: https://github.com/rails/rails/tree/v6.1.0/actionview
246
- post_install_message:
245
+ source_code_uri: https://github.com/rails/rails/tree/v6.1.1/actionview
246
+ post_install_message:
247
247
  rdoc_options: []
248
248
  require_paths:
249
249
  - lib
@@ -259,8 +259,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
259
259
  version: '0'
260
260
  requirements:
261
261
  - none
262
- rubygems_version: 3.1.4
263
- signing_key:
262
+ rubygems_version: 3.2.3
263
+ signing_key:
264
264
  specification_version: 4
265
265
  summary: Rendering framework putting the V in MVC (part of Rails).
266
266
  test_files: []