actionview 7.2.2 → 8.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d36a936637e81dec2dbe6b3b1d682f1ff3aa288f61fbb599b2252a6751ddcf39
4
- data.tar.gz: fe72769422f0081cce1d19c7541c3e65d9af340638ef9e6ad19498cfb177cff9
3
+ metadata.gz: 70ebf7c67faca6f39975eb9ee436f650efa7dd206c5e83e3edbb4b49f081dbba
4
+ data.tar.gz: a910a992ca69d738df2b9cf724311e23829e935a2c3cbcd4e5a2cce74b9e2b6d
5
5
  SHA512:
6
- metadata.gz: f736b28b5615007f33f519c8f89e380d82f0a85fdbfcdcaaa12791eb24edd18ac105e61e147f78c261d8d7d710e6ebe9ee3556b74a43991473531206256283d3
7
- data.tar.gz: 61e9ef65307525860ea8914e207138195e19bc804053503d8ee4e8897ed7cbe6e8e016a05e02fba25696ef4ed48cd65644b9421c86f10adaae458fcbc6e88788
6
+ metadata.gz: 1b275836361efefd7d7065068c91365751bbf7d4209fd9df68fe8056a3e0c990ce7d2c6c5b87db1e7c6ac3fb129ea57dabab0e95627098b625316a7bfbfbcddf
7
+ data.tar.gz: 74c9c45608b1e5a88bb34ffa5f4487cf3a2e725c95e4edb145708d055766573f2c1be9d352c3cfbbed349755ed28a59b5d9b2210e1286c776bd53354f983efbc
data/CHANGELOG.md CHANGED
@@ -1,128 +1,48 @@
1
- ## Rails 7.2.2 (October 30, 2024) ##
1
+ ## Rails 8.0.0 (November 07, 2024) ##
2
2
 
3
3
  * No changes.
4
4
 
5
5
 
6
- ## Rails 7.2.1.2 (October 23, 2024) ##
6
+ ## Rails 8.0.0.rc2 (October 30, 2024) ##
7
7
 
8
8
  * No changes.
9
9
 
10
10
 
11
- ## Rails 7.2.1.1 (October 15, 2024) ##
12
-
13
- * No changes.
14
-
15
-
16
- ## Rails 7.2.1 (August 22, 2024) ##
17
-
18
- * No changes.
11
+ ## Rails 8.0.0.rc1 (October 19, 2024) ##
19
12
 
13
+ * Remove deprecated support to passing a content to void tag elements on the `tag` builder.
20
14
 
21
- ## Rails 7.2.0 (August 09, 2024) ##
15
+ *Rafael Mendonça França*
22
16
 
23
- * Fix templates with strict locals to also include `local_assigns`.
17
+ * Remove deprecated support to passing `nil` to the `model:` argument of `form_with`.
24
18
 
25
- Previously templates defining strict locals wouldn't receive the `local_assigns`
26
- hash.
19
+ *Rafael Mendonça França*
27
20
 
28
- *Jean Boussier*
29
21
 
30
- * Add queries count to template rendering instrumentation.
22
+ ## Rails 8.0.0.beta1 (September 26, 2024) ##
31
23
 
32
- ```
33
- # Before
34
- Completed 200 OK in 3804ms (Views: 41.0ms | ActiveRecord: 33.5ms | Allocations: 112788)
24
+ * Enable DependencyTracker to evaluate renders with trailing interpolation.
35
25
 
36
- # After
37
- Completed 200 OK in 3804ms (Views: 41.0ms | ActiveRecord: 33.5ms (2 queries, 1 cached) | Allocations: 112788)
26
+ ```erb
27
+ <%= render "maintenance_tasks/runs/info/#{run.status}" %>
38
28
  ```
39
29
 
40
- *fatkodima*
41
-
42
- * Raise `ArgumentError` if `:renderable` object does not respond to `#render_in`.
43
-
44
- *Sean Doyle*
45
-
46
- * Add the `nonce: true` option for `stylesheet_link_tag` helper to support automatic nonce generation for Content Security Policy.
47
-
48
- Works the same way as `javascript_include_tag nonce: true` does.
49
-
50
- *Akhil G Krishnan*, *AJ Esler*
51
-
52
- * Parse `ActionView::TestCase#rendered` HTML content as `Nokogiri::XML::DocumentFragment` instead of `Nokogiri::XML::Document`.
53
-
54
- *Sean Doyle*
55
-
56
- * Rename `ActionView::TestCase::Behavior::Content` to `ActionView::TestCase::Behavior::RenderedViewContent`.
57
-
58
- Make `RenderedViewContent` inherit from `String`. Make private API with `:nodoc:`
59
-
60
- *Sean Doyle*
61
-
62
- * Deprecate passing `nil` as value for the `model:` argument to the `form_with` method.
63
-
64
- *Collin Jilbert*
65
-
66
- * Alias `field_set_tag` helper to `fieldset_tag` to match `<fieldset>` element.
67
-
68
- *Sean Doyle*
69
-
70
- * Deprecate passing content to void elements when using `tag.br` type tag builders.
30
+ Previously, the DependencyTracker would ignore this render, but now it will
31
+ mark all partials in the "maintenance_tasks/runs/info" folder as
32
+ dependencies.
71
33
 
72
34
  *Hartley McGuire*
73
35
 
74
- * Fix the `number_to_human_size` view helper to correctly work with negative numbers.
75
-
76
- *Earlopain*
77
-
78
- * Automatically discard the implicit locals injected by collection rendering for template that can't accept them.
36
+ * Rename `text_area` methods into `textarea`
79
37
 
80
- When rendering a collection, two implicit variables are injected, which breaks templates with strict locals.
38
+ Old names are still available as aliases.
81
39
 
82
- Now they are only passed if the template will actually accept them.
83
-
84
- *Yasha Krasnou*, *Jean Boussier*
85
-
86
- * Fix `@rails/ujs` calling `start()` an extra time when using bundlers.
87
-
88
- *Hartley McGuire*, *Ryunosuke Sato*
40
+ *Sean Doyle*
89
41
 
90
- * Fix the `capture` view helper compatibility with HAML and Slim.
42
+ * Rename `check_box*` methods into `checkbox*`.
91
43
 
92
- When a blank string was captured in HAML or Slim (and possibly other template engines)
93
- it would instead return the entire buffer.
44
+ Old names are still available as aliases.
94
45
 
95
46
  *Jean Boussier*
96
47
 
97
- * Updated `@rails/ujs` files to ignore certain data-* attributes when element is contenteditable.
98
-
99
- This fix was already landed in >= 7.0.4.3, < 7.1.0.
100
- [[CVE-2023-23913](https://github.com/advisories/GHSA-xp5h-f8jf-rc8q)]
101
-
102
- *Ryunosuke Sato*
103
-
104
- * Added validation for HTML tag names in the `tag` and `content_tag` helper method.
105
-
106
- The `tag` and `content_tag` method now checks that the provided tag name adheres to the HTML
107
- specification. If an invalid HTML tag name is provided, the method raises an `ArgumentError`
108
- with an appropriate error message.
109
-
110
- Examples:
111
-
112
- ```ruby
113
- # Raises ArgumentError: Invalid HTML5 tag name: 12p
114
- content_tag("12p") # Starting with a number
115
-
116
- # Raises ArgumentError: Invalid HTML5 tag name: ""
117
- content_tag("") # Empty tag name
118
-
119
- # Raises ArgumentError: Invalid HTML5 tag name: div/
120
- tag("div/") # Contains a solidus
121
-
122
- # Raises ArgumentError: Invalid HTML5 tag name: "image file"
123
- tag("image file") # Contains a space
124
- ```
125
-
126
- *Akhil G Krishnan*
127
-
128
- Please check [7-1-stable](https://github.com/rails/rails/blob/7-1-stable/actionview/CHANGELOG.md) for previous changes.
48
+ Please check [7-2-stable](https://github.com/rails/rails/blob/7-2-stable/actionview/CHANGELOG.md) for previous changes.
@@ -74,7 +74,7 @@ module ActionView
74
74
  end
75
75
 
76
76
  def dependencies
77
- render_dependencies + explicit_dependencies
77
+ WildcardResolver.new(@view_paths, render_dependencies + explicit_dependencies).resolve
78
78
  end
79
79
 
80
80
  attr_reader :name, :template
@@ -90,15 +90,15 @@ module ActionView
90
90
  end
91
91
 
92
92
  def render_dependencies
93
- render_dependencies = []
93
+ dependencies = []
94
94
  render_calls = source.split(/\brender\b/).drop(1)
95
95
 
96
96
  render_calls.each do |arguments|
97
- add_dependencies(render_dependencies, arguments, LAYOUT_DEPENDENCY)
98
- add_dependencies(render_dependencies, arguments, RENDER_ARGUMENTS)
97
+ add_dependencies(dependencies, arguments, LAYOUT_DEPENDENCY)
98
+ add_dependencies(dependencies, arguments, RENDER_ARGUMENTS)
99
99
  end
100
100
 
101
- render_dependencies.uniq
101
+ dependencies
102
102
  end
103
103
 
104
104
  def add_dependencies(render_dependencies, arguments, pattern)
@@ -116,12 +116,37 @@ module ActionView
116
116
  end
117
117
 
118
118
  def add_static_dependency(dependencies, dependency, quote_type)
119
- if quote_type == '"'
120
- # Ignore if there is interpolation
121
- return if dependency.include?('#{')
122
- end
119
+ if quote_type == '"' && dependency.include?('#{')
120
+ scanner = StringScanner.new(dependency)
121
+
122
+ wildcard_dependency = +""
123
+
124
+ while !scanner.eos?
125
+ if scanner.scan_until(/\#{/)
126
+ unmatched_brackets = 1
127
+ wildcard_dependency << scanner.pre_match
128
+
129
+ while unmatched_brackets > 0 && !scanner.eos?
130
+ found = scanner.scan_until(/[{}]/)
131
+ return unless found
132
+
133
+ case scanner.matched
134
+ when "{"
135
+ unmatched_brackets += 1
136
+ when "}"
137
+ unmatched_brackets -= 1
138
+ end
139
+ end
140
+
141
+ wildcard_dependency << "*"
142
+ else
143
+ wildcard_dependency << scanner.rest
144
+ scanner.terminate
145
+ end
146
+ end
123
147
 
124
- if dependency
148
+ dependencies << wildcard_dependency
149
+ elsif dependency
125
150
  if dependency.include?("/")
126
151
  dependencies << dependency
127
152
  else
@@ -130,24 +155,8 @@ module ActionView
130
155
  end
131
156
  end
132
157
 
133
- def resolve_directories(wildcard_dependencies)
134
- return [] unless @view_paths
135
- return [] if wildcard_dependencies.empty?
136
-
137
- # Remove trailing "/*"
138
- prefixes = wildcard_dependencies.map { |query| query[0..-3] }
139
-
140
- @view_paths.flat_map(&:all_template_paths).uniq.filter_map { |path|
141
- path.to_s if prefixes.include?(path.prefix)
142
- }.sort
143
- end
144
-
145
158
  def explicit_dependencies
146
- dependencies = source.scan(EXPLICIT_DEPENDENCY).flatten.uniq
147
-
148
- wildcards, explicits = dependencies.partition { |dependency| dependency.end_with?("/*") }
149
-
150
- (explicits + resolve_directories(wildcards)).uniq
159
+ source.scan(EXPLICIT_DEPENDENCY).flatten.uniq
151
160
  end
152
161
  end
153
162
  end
@@ -10,7 +10,7 @@ module ActionView
10
10
  end
11
11
 
12
12
  def dependencies
13
- render_dependencies + explicit_dependencies
13
+ WildcardResolver.new(view_paths, render_dependencies + explicit_dependencies).resolve
14
14
  end
15
15
 
16
16
  def self.supports_view_paths? # :nodoc:
@@ -31,29 +31,12 @@ module ActionView
31
31
  compiled_source = template.handler.call(template, template.source)
32
32
 
33
33
  @parser_class.new(@name, compiled_source).render_calls.filter_map do |render_call|
34
- next if render_call.end_with?("/_")
35
34
  render_call.gsub(%r|/_|, "/")
36
35
  end
37
36
  end
38
37
 
39
38
  def explicit_dependencies
40
- dependencies = template.source.scan(EXPLICIT_DEPENDENCY).flatten.uniq
41
-
42
- wildcards, explicits = dependencies.partition { |dependency| dependency.end_with?("/*") }
43
-
44
- (explicits + resolve_directories(wildcards)).uniq
45
- end
46
-
47
- def resolve_directories(wildcard_dependencies)
48
- return [] unless view_paths
49
- return [] if wildcard_dependencies.empty?
50
-
51
- # Remove trailing "/*"
52
- prefixes = wildcard_dependencies.map { |query| query[0..-3] }
53
-
54
- view_paths.flat_map(&:all_template_paths).uniq.filter_map { |path|
55
- path.to_s if prefixes.include?(path.prefix)
56
- }.sort
39
+ template.source.scan(EXPLICIT_DEPENDENCY).flatten.uniq
57
40
  end
58
41
  end
59
42
  end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActionView
4
+ class DependencyTracker # :nodoc:
5
+ class WildcardResolver # :nodoc:
6
+ def initialize(view_paths, dependencies)
7
+ @view_paths = view_paths
8
+
9
+ @wildcard_dependencies, @explicit_dependencies =
10
+ dependencies.partition { |dependency| dependency.end_with?("/*") }
11
+ end
12
+
13
+ def resolve
14
+ return explicit_dependencies.uniq if !view_paths || wildcard_dependencies.empty?
15
+
16
+ (explicit_dependencies + resolved_wildcard_dependencies).uniq
17
+ end
18
+
19
+ private
20
+ attr_reader :explicit_dependencies, :wildcard_dependencies, :view_paths
21
+
22
+ def resolved_wildcard_dependencies
23
+ # Remove trailing "/*"
24
+ prefixes = wildcard_dependencies.map { |query| query[0..-3] }
25
+
26
+ view_paths.flat_map(&:all_template_paths).uniq.filter_map { |path|
27
+ path.to_s if prefixes.include?(path.prefix)
28
+ }.sort
29
+ end
30
+ end
31
+ end
32
+ end
@@ -10,6 +10,7 @@ module ActionView
10
10
 
11
11
  autoload :ERBTracker
12
12
  autoload :RubyTracker
13
+ autoload :WildcardResolver
13
14
 
14
15
  @trackers = Concurrent::Map.new
15
16
 
@@ -7,9 +7,9 @@ module ActionView
7
7
  end
8
8
 
9
9
  module VERSION
10
- MAJOR = 7
11
- MINOR = 2
12
- TINY = 2
10
+ MAJOR = 8
11
+ MINOR = 0
12
+ TINY = 0
13
13
  PRE = nil
14
14
 
15
15
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "set"
4
-
5
3
  module ActionView
6
4
  module Helpers # :nodoc:
7
5
  # = Action View Atom Feed \Helpers
@@ -93,6 +93,14 @@ module ActionView
93
93
  # render partial: 'attachments/attachment', collection: group_of_attachments
94
94
  # render partial: 'documents/document', collection: @project.documents.where(published: true).order('created_at')
95
95
  #
96
+ # One last type of dependency can be determined implicitly:
97
+ #
98
+ # render "maintenance_tasks/runs/info/#{run.status}"
99
+ #
100
+ # Because the value passed to render ends in interpolation, Action View
101
+ # will mark all partials within the "maintenance_tasks/runs/info" folder as
102
+ # dependencies.
103
+ #
96
104
  # === Explicit dependencies
97
105
  #
98
106
  # Sometimes you'll have template dependencies that can't be derived at all. This is typically
@@ -1228,7 +1228,7 @@ module ActionView
1228
1228
  class FormBuilder
1229
1229
  # Wraps ActionView::Helpers::DateHelper#date_select for form builders:
1230
1230
  #
1231
- # <%= form_for @person do |f| %>
1231
+ # <%= form_with model: @person do |f| %>
1232
1232
  # <%= f.date_select :birth_date %>
1233
1233
  # <%= f.submit %>
1234
1234
  # <% end %>
@@ -1240,7 +1240,7 @@ module ActionView
1240
1240
 
1241
1241
  # Wraps ActionView::Helpers::DateHelper#time_select for form builders:
1242
1242
  #
1243
- # <%= form_for @race do |f| %>
1243
+ # <%= form_with model: @race do |f| %>
1244
1244
  # <%= f.time_select :average_lap %>
1245
1245
  # <%= f.submit %>
1246
1246
  # <% end %>
@@ -1252,7 +1252,7 @@ module ActionView
1252
1252
 
1253
1253
  # Wraps ActionView::Helpers::DateHelper#datetime_select for form builders:
1254
1254
  #
1255
- # <%= form_for @person do |f| %>
1255
+ # <%= form_with model: @person do |f| %>
1256
1256
  # <%= f.datetime_select :last_request_at %>
1257
1257
  # <%= f.submit %>
1258
1258
  # <% end %>