react-wrap-balancer icon indicating copy to clipboard operation
react-wrap-balancer copied to clipboard

Fix: skip Balancer script if global one is already created

Open mixeden opened this issue 2 years ago • 1 comments
trafficstars

Hi, this is a great library, thanks for developing it :)

The problem I stumbled upon (and am fixing in this PR) is as follows.

There are two ways to use this library:

  • You use Balancer without a Provider. In this case, each Balancer has its own script that calculates the layout and does other things.
  • You use a Balancer with a Provider. In this case, they all have one common script that calculates the layout.

Now imagine you have a strict CSP and you need to pass a nonce. You pass the nonce to the Provider and do not pass it to Balancers.

This lib creates an empty script tag for each Balancer in case of global script injection. Since you don't pass the nonce to each Balancer, the CSP doesn't work (as there still is a script for each Balancer).

I fixed this by just not returning any script tag in case of global script injection. Seems that this PR is associated with https://github.com/shuding/react-wrap-balancer/issues/78, but I'm not sure

mixeden avatar Nov 13 '23 18:11 mixeden

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-wrap-balancer ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 13, 2023 6:57pm

vercel[bot] avatar Nov 13 '23 18:11 vercel[bot]