Skip to content

Conversation

@sanderdlm
Copy link

@sanderdlm sanderdlm commented Oct 1, 2021

Having our jsData as an inline script is not ideal. It's a possible vulnerability and we have to trust that it will be present in our style package.

Symfony also recommends different ways to pass data from Twig to JS: https://symfony.com/doc/current/frontend/encore/server-data.html. The locale we used to pass in the jsData is already present as the lang attribute, which we can read in JS with

document.getQuerySelector('html'].getAttribute('lang');

This only leaves the current theme and the path to the dark style CSS file. With this PR I propose we set both as data attributes on our body tag, as suggested by the Symfony docs. We can verify if they're properly set and then read their values in our style package.

PR in style package: sumocoders/FrameworkStylePackage#65

@sanderdlm sanderdlm requested a review from a team October 1, 2021 13:25
@sanderdlm sanderdlm force-pushed the refactor-jsdata-and-theme branch from 241a6fe to 6ad3732 Compare November 17, 2021 08:45
@sanderdlm sanderdlm merged commit ee9475d into master Nov 17, 2021
@tijsverkoyen tijsverkoyen deleted the refactor-jsdata-and-theme branch December 8, 2021 13:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants