-
-
Notifications
You must be signed in to change notification settings - Fork 17
Cannot set property to false #14
Comments
Because the HAST value For the spec, it’s described here, in property values. Why do you think this shouldn’t be the case? How are you creating the AST? |
I am using this library as part of markdown <-> react engine So from what i get is that booleans has to be by definition default to false and only if mentioned they should be treated as false :/ |
Well, what the property mapper? I believe it's a big there 🤷♂️ |
bug* gah sorry! |
I have same issue. My usecase is to generate realtime preview for markdown editor.
I read property values, but I'm not sure why the value of It says "non-standard values are retained to allow plug-ins and utilities to inspect them" and " I think that falsy values (except In React, properties must be always passing or non-passing. Flipping(passing or not) causes a warning as below:
working sample is here: https://berlysia.github.io/example-for-hast-to-hyperscript-14/ |
i was changing my implemenation abit so it will act as menetioned here. |
@berlysia Is the problem maybe that |
In short: No.
As documented in Uncontrolled Components - Default values,
Also I verified to use It's suitable to use |
@DxCx Ahh okay, thanks for clarifying! As HAST can represent all of HTML, and all properties on inputs (and other elements) could change, implementing just |
However, because of property values, this issue can apply to all properties on all elements in HTML. HAST can represents superset of HTML. Filtering inappropriate values would have better to be the responsibility of the consumer side (as your |
Alright, I’m convinced! Could we try and ignore these two lines? Maybe it works for all other hyperscripts, but if not, we can scope this to just react? |
For clarification, could you tell me what is "these two lines"? |
@DxCx Ping! |
Well, yeah thats what i believe, at least null.. |
I have a similiar issue. In my case it is not a false value, but an array. My node has properties like: {
params: ["param1", "param2", "param3"]
} These lines in hast-to-hyperscript serializes the array into a string if (value !== null && typeof value === 'object' && 'length' in value) {
// Accept `array`. Most props are space-separater.
value = (info.commaSeparated ? commas : spaces).stringify(value)
} As was the case with the false values, when dealing with react elements, I would expect the properties to apply to the react element as-is. So that the react elements receive the actual properties that are present in the HAST. Would it be possible to not transform the properties in case of react elements? |
Could you open a new issue? Otherwise it’s very easy to loose this comment. |
Hey,
I have html ast which i am parsing, with some of the properties being "false" (bool false not string).
they are boolean properties and i expect them to be either true or false.
After a processing of hast-to-hyperscript, those props are completely gone.
browsing the code abit, ive found those lines:
hast-to-hyperscript/index.js
Lines 147 to 156 in 5dd6b51
(specificlly line 151 (value === false))
which i can understand why would you filter null and undefined, i don't understand why false is being filtered.
looking at the hast github again, i dont see any reasoning for that..
can you please explain this behavior? or maybe that is just a bug?
The text was updated successfully, but these errors were encountered: