Simple and lightweight (< 2kB) HTML string to React element conversion library
Fix non-boolean attribute treatment #138
Previously these HTML trigger react warning because it satisfies boolean attribute value requirement (value equals to attribute name, or empty string).
<img alt="alt" />
<div class=""></div>
It's rendered into
// jsx equivalent
<img alt={true} />
<div className={true}></div>
Now htmr will validate whether the attribute is boolean attribute before using boolean value. If not, the attribute will simply be forwarded as is
Example above now rendered as
// jsx equivalent
<img alt="alt" />
<div className=""></div>
First stable release! 🚀
ref
conflictdangerouslySetChildren
is now allowedPreviously, these don't work
htmr('<style></style>');
htmr('<script></script>', { dangerouslySetChildren: ['script'] });
htmlparser2
to v6
HtmrOptions
as top-level named exportimport { HtmrOptions } from 'htmr'
const transform: HtmrOptions = {
a: props => {
// props is now automatically inferred
if (props.href.startsWith('http') {
}
}
}
const transform: HtmrOptions = {
svg: props => {
return <>{props.viewBox}</>
}
}
viewBox
warning when rendering svg
elementfix server-side parser for script tag (#115)
Fixed XSS issue in DOM based parser
Fixed transform
doesn't get applied when using dangerouslySetChildren