-
Notifications
You must be signed in to change notification settings - Fork 197
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
Add toNonceUnstyled functions for CSP nonce support #570
Conversation
Anything we can do to help get this in @rtfeldman ? :) |
@jfmengels For future-proofing the "API", do you think having a |
@JohanWinther That depends on what Html.toUnstyledWith
{ nonce = Just "nonce id"
, -- ...
}
(view model) I think the API looks okay in that case, but it is not future-proof, because any addition/change you make to that record is a breaking change. To make it future-proof, you can use the builder pattern: Html.toUnstyledWith
(Html.defaultOptions
|> Html.withNonce "nonce id"
)
(model view) The ergonomics become quite different, and not necessarily idiomatic to the rest of the package. In addition, the The Html List pattern, with Html.toUnstyledWith
[ Html.nonce "nonce id"
]
(model view) But then the question becomes: What do we need to future proof for? I haven't followed feature requests for this repo enough, but this seems to be the first option since last the few years that Anyway. If there is no use-case for a list of options, I don't think it's worth adding. But happy to add it if maintainers wish for it. |
@jfmengels I think you are on to something about not needing to future proof. I was looking at the way I'm looking forward to this change, mainly because I'm working at the same company (but different team) as @jonathanmoregard and my team will probably have the same problem to solve in the near future. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lovely, thanks @jfmengels! 🎉
I think I'm missing something while trying to use
and traced it down by modifying the elm output js for (var key in attrs)
{
var value = attrs[key];
+ if (key === 'style') {
+ console.log(value !== 'undefined' ? 'setAttribute' : 'removeAttribute', key, value, domNode);
+ continue;
+ }
typeof value !== 'undefined'
? domNode.setAttribute(key, value)
: domNode.removeAttribute(key); to see this single line logged which is from #559 Lines 108 to 111 in c5ffa8c
elm-css/src/VirtualDom/Styled.elm Lines 483 to 486 in c5ffa8c
How do I avoid that? NOTE: I have |
According to https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/style-src#violation_cases, inline style attributes (like in Current |
Typed CSS is nice and also not needing to think about CSS output was nice. However it's a dead end with Content-Security-Policy. Our aim with Browser is to be as compatible with various apps as possible so it was limiting Browser adoption too much. rtfeldman/elm-css#569 (comment) rtfeldman/elm-css#570 (comment) https://arkency.slack.com/files/U025BA51D/F03LJ1UPZQV/audio_clip__2022-06-22_01_11_39_.m4a Previous idea with nonce that did not work out: https://arkency.slack.com/archives/C7B95EW3V/p1655828630714969 Related: https: //github.com//issues/1346 Co-authored-by: Szymon Fiedler <szymon.fiedler@gmail.com>
Fixes #569
Happy to make any changes, and to take suggestions for better documentation of the function 🙂