-
-
Notifications
You must be signed in to change notification settings - Fork 923
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
Some boolean attributes/properties with weird behavior #2809
Comments
It is different from most other attributes in that when not set, it defaults to true, thus there are scenarios where you want it statically set to false. |
Ooooh... So we must fix it. This is a |
I imagine the special case would not be based on the property name but when the property type is bool and the assigned value is the string "false"? |
The problem here comes from the facts that
Our logic AFAIK handles most of actual attributes/properties fine, because attributes with literal We can't just add With that said, implementing your suggestion may break existing user code, so I'd rather be conservative and add a special case for We may revisit this for the next major version. Edit: actually, since |
Investigating the problem space, this is a temporary braindump. I've extracted the attribute list from MDN using const attrMap = entries.map(tr => [
tr.children[0].textContent,
tr.children[1].textContent === "Global attribute"
? ['div']
: tr.children[1].textContent.trim().split(/\s*,\s*/g).map(s => s.replace(/^<|^\\x3C|>$/g, ''))
]) This doesn't list the From there, we can list the attributes that double up as properties, and, if these are boolean, their default values. Of these, three may need special attention:
TODO: investigate aria, SVG edit: The script above didn't properly clean up the attr names, and I had missed edit2: recapitulating: Currently rendering |
Just want to reference MithrilJS/mithril.d.ts#46 (comment) which while a tad unrelated in the scope of the issue it does pertain to attribute structures and more specifically object prop > value expressed. While I know a lot of the hardcore SWE are not adopting TS when it comes to things like this it’s golden shackles. |
m([spellcheck=false])
results in <div spellcheck="true">
I'm leaning towards a "no" for this. The DOM APIs all accept and return strings, and the HTML attributes have to be stuff like Not closing yet, because I'd like to solicit a little more discussion for this before shutting the door on it. |
Edit: The original title was "Rendering
m([spellcheck=false])
results in<div spellcheck="true">
", but there are more issues, see below.As mentioned in MithrilJS/docs#20 by @anonghuser,
m([spellcheck=false])
results in<div spellcheck="true">
, it should obviously be false.I don't know if this should be fixed though. In scenarios where you want it not set, statically, you can omit the attribute. For dynamic scenarios the
attrs
object is a better method.The text was updated successfully, but these errors were encountered: