Actually export doNotRenderBBCodeComponent() from index.ts this time
For full transparency, this update does have roughly a roughly 15% hit to performance on paper. In practice, this is likely to be completely negligible (especially given more real-world workloads than Stephen Li [Trinovantes]'s built-in benchmarking), but it is worth noting for full transparency.
- Adjust handling of component children, including fixing a bug where
skipChildrenwas not being honored (meaning excess renders were being performed) - Adjust handling of render failing...
- fixing a bug where components which would not be rendered would simply not appear (rather than displaying their raw text)
- requiring that all render failures now either call
doNotRenderBBCodeComponent()or throwDoNotRenderBBCodeError(see below)
- Rename
Transform.componenttoTransform.Componentto better satisfy React naming conventions and linters which rely on them
These new exports are for use when a component should not be rendered (such as when an unsafe URL is detected). When encountered by the compiler, the component will not be rendered.
The doNotRenderBBCodeComponent() function returns the TypeScript type never which TS understands to be the same as throwing an error or returning. You therefore are not strictly required to use return after calling doNotRenderBBCodeComponent() (though it helps with readability in IDEs with syntax highlighting).
The DoNotRenderBBCodeError is a class which extends Error and is thrown when a component should not be rendered. While I can't think of much of a use case for this, it is provided for completeness under bbcode-compiler-react/advanced.
- Add optional
doDangerCheckparameter toparseMaybeRelativeUrl()(defaults to true to mirror 1.0.0 behavior) - Component keys are now the nodes stringified normally (rather than plain iterator indices) to make React happier
- Errors thrown during tag rendering will now append to the stack the tag that caused the error and a TagNode object for debugging passed passed through Json.stringify()
- This behavior will only apply if the symbol
BBCodeOriginalStackTraceis not set to the old stack trace on the error object. This is exported frombbcode-compiler-react/advancedif you wish to use it in your own error handling.
- This behavior will only apply if the symbol
- Transform's Component method will now show the name
BBCode_${tagName}(e.g.BBCode_bfor [b]) if no custom function name is provided
- In rare cases, the
childrenparameter could be a two-dimensional array. This array is now flattened.- Important note - you should NOT be relying on the
childrenparameter in your components; you should prefer to gather data from thetagNodeproperty.
- Important note - you should NOT be relying on the
- For transforms which have
skipChildren, thechildrenparameter will now always beundefined - Added JSDoc to:
parseMaybeRelativeUrl()isDangerousUrl()
- Revised JSDoc for:
Transform.Component
Initial release