Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix running with RUBYOPT="--enable-frozen-string-literal" #651

Merged
merged 3 commits into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions lib/will_paginate/view_helpers/link_renderer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,12 @@ def link(text, target, attributes = {})
end

def tag(name, value, attributes = {})
string_attributes = attributes.inject('') do |attrs, pair|
string_attributes = attributes.map do |pair|
unless pair.last.nil?
attrs << %( #{pair.first}="#{CGI::escapeHTML(pair.last.to_s)}")
%( #{pair.first}="#{CGI::escapeHTML(pair.last.to_s)}")
end
attrs
end
"<#{name}#{string_attributes}>#{value}</#{name}>"
"<#{name}#{string_attributes.compact.join("")}>#{value}</#{name}>"
end

def rel_value(page)
Expand Down
3 changes: 1 addition & 2 deletions spec/view_helpers/action_view_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,13 @@ def renderer.gap() '<span class="my-gap">~~</span>' end

it "should match expected markup" do
paginate
expected = <<-HTML
expected = <<-HTML.strip.gsub(/\s{2,}/, ' ')
<div class="pagination" role="navigation" aria-label="Pagination"><span class="previous_page disabled" aria-label="Previous page">&#8592; Previous</span>
<em class="current" aria-label="Page 1" aria-current="page">1</em>
<a href="/foo/bar?page=2" aria-label="Page 2" rel="next">2</a>
<a href="/foo/bar?page=3" aria-label="Page 3">3</a>
<a href="/foo/bar?page=2" class="next_page" rel="next" aria-label="Next page">Next &#8594;</a></div>
HTML
expected.strip!.gsub!(/\s{2,}/, ' ')
expected_dom = parse_html_document(expected)

if expected_dom.respond_to?(:canonicalize)
Expand Down