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

attr.maybe should offer similar API to attr #89

Open
raquo opened this issue Feb 28, 2021 · 0 comments
Open

attr.maybe should offer similar API to attr #89

raquo opened this issue Feb 28, 2021 · 0 comments
Labels
enhancement ergonomics need to find time https://falseknees.com/297.html needs design The solution is not clear, or I am not very happy with it

Comments

@raquo
Copy link
Owner

raquo commented Feb 28, 2021

Currently only attr.maybe(someValue) is possible, but not attr.maybe := someValue or attr.maybe <-- $someValue. We could implement these with some work.

The main problem is, we don't know the default value of each attr / prop / css key.

But...

  • For keys that are Attr or ReflectedAttr, we could probably use Javascript's removeAttribute method
  • For CSS props we could probably use CSSStyleDeclaration.removeProperty
  • This leaves pure, non-attribute props, but we only have a handful of them, so although there is no generic solution, false and "" will work for those specific props.

Main complication is that ReflectedAttrs currently uses the Props class from SDT which doesn't carry any info about the corresponding attribute name. But SDT itself does provide this information. So we will probably need a custom Props class in Laminar for this.

We could also potentially use the property's current value (at the time the maybe modifier is added) as its default value, but I could see this being confusing if the user has previously set some value to this property. But actually, if we don't do this, the behaviour of attr.maybe(someValue) and attr.maybe <-- Val(someValue) would be different. Hm...

@raquo raquo added the need to find time https://falseknees.com/297.html label Jan 6, 2023
@raquo raquo added the needs design The solution is not clear, or I am not very happy with it label Jan 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement ergonomics need to find time https://falseknees.com/297.html needs design The solution is not clear, or I am not very happy with it
Projects
None yet
Development

No branches or pull requests

1 participant