Skip to content
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

Don't throw on nil :__html value #102

Merged
merged 1 commit into from
Mar 31, 2023
Merged

Conversation

chrisetheridge
Copy link

This fixes #101

This is how React handles nil from what I can see

Added tests cases for both paths!

#?(:clj
(deftest nil-dangerously-set-inner-html
(is (= (render ($ username {:username nil})) "<p></p>"))
(is (thrown? Exception (render ($ bad-username {:foo 1}))))))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this test fail since the rendering code checks for presence of a key?

this is also how React SSR works, they only check for presence of a key https://codesandbox.io/s/suspicious-gould-f3jxg9?file=/src/index.js

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which test exactly? The first or second is check?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uh, sorry, I miss read the change, looks good! :D

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you made me super confused :D had to re-read the code a couple times!

@roman01la roman01la self-requested a review March 31, 2023 12:17
@roman01la roman01la merged commit 966648d into pitch-io:master Mar 31, 2023
@chrisetheridge chrisetheridge deleted the nil-html branch March 31, 2023 12:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

nil value cannot be used for dangerouslySetInnerHTML on server side
2 participants