Use to_json in simple view hash data-props build locations (#38218)

This commit is contained in:
Matt Jankowski
2026-03-16 10:02:52 -04:00
committed by GitHub
parent 330357507d
commit 1a464bc5ed
6 changed files with 9 additions and 3 deletions

View File

@@ -8,7 +8,7 @@
= render_initial_state
= vite_typescript_tag 'application.ts', crossorigin: 'anonymous'
.notranslate.app-holder#mastodon{ data: { props: Oj.dump(default_props) } }
.notranslate.app-holder#mastodon{ data: { props: default_props.to_json } }
%noscript
= image_tag frontend_asset_path('images/logo.svg'), alt: 'Mastodon'

View File

@@ -2,4 +2,4 @@
= render_initial_state
= vite_typescript_tag 'share.tsx', crossorigin: 'anonymous'
#mastodon-compose{ data: { props: Oj.dump(default_props) } }
#mastodon-compose{ data: { props: default_props.to_json } }

View File

@@ -1 +1 @@
#mastodon-status{ data: { props: Oj.dump(default_props.merge(id: @status.id.to_s)) } }
#mastodon-status{ data: { props: default_props.merge(id: @status.id.to_s).to_json } }

View File

@@ -41,6 +41,8 @@ RSpec.describe 'Status embed' do
.to have_http_status(200)
expect(response.parsed_body.at('body.embed'))
.to be_present
expect(response.parsed_body.at('#mastodon-status')['data-props'])
.to eq({ locale: 'en', id: status.id.to_s }.to_json)
expect(response.headers).to include(
'Vary' => 'Accept, Accept-Language, Cookie',
'Cache-Control' => include('public'),

View File

@@ -12,6 +12,8 @@ RSpec.describe 'Home page' do
expect(page)
.to have_css('noscript', text: /Mastodon/)
.and have_css('body', class: 'app-body')
expect(find('.app-holder#mastodon')['data-props'])
.to eq('{"locale":"en"}')
end
end

View File

@@ -19,6 +19,8 @@ RSpec.describe 'Share page', :js, :streaming do
.to have_css('.modal-layout__mastodon')
.and have_css('div#mastodon-compose')
.and have_css('.compose-form__submit')
expect(find_by_id('mastodon-compose')['data-props'])
.to eq('{"locale":"en"}')
fill_in_form