-
-
Notifications
You must be signed in to change notification settings - Fork 924
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
Discussion for v2: make the attrs take precedence over what the selector provides #2172
Comments
On top of the above, what should
If the attrs take precedence over the selector, though, Or maybe this whole discussion is misguided, and we should keep the current behaviour where the selector has precedence... |
Non-special attributes should override their selector-defined counterparts. I can't think of a salient scenario where someone might define an attribute in the selector then have a conditionally nullish counterpart in the attrs hash, expecting it to fall back to the selector value. Compound className definition should definitely have nullish fall through to 'nothing to add' as opposed to 'delete' though. |
Let's try that... Leaving this open for now, I'm not entirely convinced this is the way to go. |
…, improve class normalization fix MithrilJS#1773 fix MithrilJS#2172
…, improve class normalization fix MithrilJS#1773 fix MithrilJS#2172
I support direction of @barneycarroll point, that mithril should do less magic, should keep simple logic in vnode level. Or even, I'd like ignore all nullish value in attrs, that's what null comes to: nothing can do. like below: m('', {onclick: null}) In any way it should generate same vnode to: m('') Strictly. |
Where to discuss other features in V2? |
@futurist You look for issues and PRs with the breaking change proposal label, or open a new one if something is not addressed yet. Edit: You can also look at the change log for more things that are already in. Regarding nullish attrs, that's how Agreed in general regarding the "less magic" mantra. |
Currently,
results in:
In other words, the selector has precedence over the attrs. This kind of made sense as an optimization prior to this PR, (so that classes would end up set on
className
which is faster to set according to Leo). But it may be useful to let the attrs take precedence, so that a common selector string can have its attrs overruled in some circumstances.Once we have that, however, comes the question of
null
-valued attrs:As far as
m.render()
is concerned, an attr with a nullish value is equivalent to a lack of attribute. How shouldm()
work in similar situations?Should
m("foo[bar=baz]", {bar: null})
produce{bar: "baz"}
or{bar: null}
as attrs?The former is easier to document, the the latter is more powerful, especially In a ES6+ world, where you can do
{...(condition ? {bar: null} : null)}
.Thoughts? This is related to #1773 which I had overlooked for v2.
The text was updated successfully, but these errors were encountered: