A Few Things...
See original GitHub issueFirst I want to start by saying this library is fantastic, thanks for your work on it. Before using this lib, I tried regexes which ended up getting overly complex and slow. I’m happy to submit PRs for everything below, just wanted to talk through some of it through beforehand.
I noticed a few bugs so far…
-
PropTypes
error from@bbob/react
(#27). -
reactPreset.extend
doesn’t work, butpresetHTML5.extend
does (#29). -
Warning: Each child in a list should have a unique "key" prop.
with react (#30). - Uppercase tags cause issues in react (see below) (#34).
-
[*]
tags inside lists don’t work in react. - I can help with some documentation (e.g. options, create a preset).
These ones are necessary, but would be nice to have…
- Expose
getUniqAttr
fromplugin-helpers
so preset authors and consumers can use it.
Uppercase Tags
For example, something like [B]
kind of works in the demo because most browsers will automatically recognize and lowercase it (at least in the inspector) so it will still be rendered. That said the styling attributes you’re adding with the b
definition are lost and the demo only shows it bold because of default browser styling.
In react however, the following error is thrown:
<B /> is using incorrect casing. Use PascalCase for React components, or lowercase for HTML elements.
To fix this issue, I simply injected a little preset before the main one to lowercase all tag names:
plugins={[
(tree, core) => {
tree.walk(node => {
if (typeof node === 'object' && node.tag) {
node.tag = node.tag.toLowerCase()
}
return node
})
},
preset()
]}
That works, but feels a little hacky so I’m thinking this probably makes sense as a built-in but I’m not sure where to put it.
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (7 by maintainers)
Top GitHub Comments
I just published 2.5.3 you can try
Yes,
TagNode
is a good way to lowercase tag.