Closed Hypercubed closed 5 years ago
Hum, i'm not sure. /o\
I you may have found in the code that it's a chose i'd made to leave the possibility to differentiate "disable"
and "disable=defaultVal"
. The second reason is about the value, "true" isn't the value that HTML use, in fact, for attribute without a value, HTML use the empty string as a default value so attr
and attr=""
are strictly the same. And finally, this plugin may be used with other plugins than rehype, in which the difference between "disable"
and "disable=defaultVal"
is maybe important. 🤷
I really think that "true"
isn't a good value but i admit that "undefined" isn't a good one either ... Maybe true
(as a boolean, not a string ?)
We may need the opinion of other members of the remark project.
Excellent point... I had assumed that the default value was true. In fact according to the HTML spec (http://w3c.github.io/html/infrastructure.html#sec-boolean-attributes):
A boolean attribute without a value assigned to it (e.g. checked) is implicitly equivalent to one that has the empty string assigned to it (i.e. checked=""). As a consequence, it represents the true value.
I'd be more than happy if md-attr-parser
set a value that was ==
to true. Unfortunately, in JS '' == false
. How about the attr name: parseAttr('{ thisKey }') -> { thisKey: "thisKey" }
?
Ok ... As we can see, depending on the use case, we may expect something different. We shouldn't make a chose for the user and let him chose himself.
I will add a configuration option to let chose the default value of a attribute without a value. ;) By the end of the weekend, I mean.
I don't know if you noticed but i did it here : 9106ddd60e315a7d61ffd3ef9e59bf6ae582387f
Will update the README about it and use it in remark-attr.
I didn't forget. I will publish a new version as soon i finished the documentation.
Done.
Hello again,
Do you think (as I do) that keys without a value should return
true
?For example
parseAttr('{ thisKey }')
should result in{ thisKey: true }
. This is consistant with how HTML attribues work.<input disabled>
is the same as<input disabled="true">
.