Special case SafeBuffer#concat(nil) to avoid the bulk of deprecations

After trying out https://github.com/rails/rails/pull/42123
it appears that the bulk of the deprecations are for cases such as:

```ruby
output << some_helper
```

Where `some_helper` happens to sometime return `nil`.

While a regular String would indeed raise a `TypeError`
on such case, I wonder if it wouldn't be worth to special
case this specific scenario as it is quite harmless and would
drastically reduce the amount of deprecated code.
This commit is contained in:
Jean Boussier 2021-05-06 10:49:15 +02:00
parent 70c5496542
commit fdb5c0463b
1 changed files with 4 additions and 1 deletions

View File

@ -184,7 +184,10 @@ module ActiveSupport #:nodoc:
end
def concat(value)
super(implicit_html_escape_interpolated_argument(value))
unless value.nil?
super(implicit_html_escape_interpolated_argument(value))
end
self
end
alias << concat