Fix mask plugin with data directive (CSP)#4090
Fix mask plugin with data directive (CSP)#4090kg-currenxie wants to merge 2 commits intoalpinejs:mainfrom
Conversation
|
I can't figure out what causes the breaking tests really :) Help appreciated 🙏 This is the last bit of a huge CSP re-write, to deploy our new app to production :) |
|
I think the improved API would probably be actually binding the function to an object with the scope/magics... also not sure why it causes an issue with the failed tests...but definitely need to figure that one out... |
not following a 100% :) do you mean passing this as the 2nd argument instead? 🤔 or 🤔 |
|
more like value.bind({ $input: input, $money: formatMoney.bind({el}) })(input)But also whatever would make |
Yea, i just came across that issue. |
|
Well, I just showed....bind the value... |
|
Sorry, i spoke too soon :P
basically im doing something like where thanks for you continuing support! 🙏 |
|
You can possibly look at how magics are injected into the state in the first place, or use mergeProxies directly to layer them. |
PR Review: #4090 — Fix mask plugin with data directive (CSP)Type: Bug fix What's happening (plain English)
Why this fix is wrongThe change is: // Before:
result = typeof value === 'function' ? value(input) : value
// After:
result = typeof value === 'function' ? value(input, formatMoney.bind({ el })) : valueProblems:
Other approaches considered
Changes MadeNo changes made. The fix is architecturally wrong. Test Results
Code ReviewThe single-line change at SecurityNo security concerns identified. VerdictClose. This PR is almost 2 years old with no maintainer approval, no tests, acknowledged broken tests, and the implementation approach is fundamentally wrong. The real fix (if needed) would be to bind the resolved function to the evaluator scope so The use case (CSP + Reviewed by Claude |
Before:
Data directive:
HTML:
After
Data directive:
HTML:
Let me know if I'm missing something, or if it would break something else?
It does work in our app's UI tho.