Open runeb opened 2 years ago
Possibly it would be best to just have the consumers of this module do this unwrapping themselves, but unfortunately this module is often not used directly, but through convenience modules like block-content-to-html
and those modules do this before the user has a chance to modify the node tree:
https://github.com/sanity-io/block-content-to-html/blob/main/src/blocksToHtml.js#L6
return rootNode.outerHTML || rootNode
Adds
renderContainer
option which defaults totrue
and the current behaviour. If set tofalse
we simply return theinnerHTML
of the normal rendering, thus avoiding the wrapping element. This was deemed to be the least intrusive way to achieve this feature.Unsure, however, if it is okay for this module to return a string versus a node with children. But the frequent usage of
rootNode.outerHTML || rootNode
in both this test suite and in downstream modules indicate that the contract is not all that clear to begin with.