Warn if ChildNode is used as modifier multiple times. #183
ivan-klass
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Recently, I've encountered an issue with some elements being not displayed where expected.
Here's a simplified and minimized example to demonstrate my case:
See https://scastie.scala-lang.org/8dB25QZfRtW0ZuamN4x88w
The root case traces back to a lack of referential transparency: an expression of the node declaration can't be assigned to a
val
and reused. That's because there is an allocation side-effect, which is probably fine to have as Laminar don't pretend to be FP framework. With mixed feelings, I've completely fixed my particular problem by simply changingval
definition todef
.If I understand correctly, using an element as a modifier is equivalent to setting a parent, and the most common case is when there were no parent before.
Given the above, I think maybe it would make sense to have a warning when element is used as modifier while the parent is already set. In case when changing the parent was intentional, maybe it's better to have an explicit mechanism (e.g. method, function, event) for that, rather than using modifier syntax?
Beta Was this translation helpful? Give feedback.
All reactions