Prosemirror-Model DOMSerializer serializeFragment interface question

prosemirror-model defines a public interface of

serializeFragment(fragment: Fragment, options: ?⁠Object = {}) → dom.DocumentFragment

in the DOMSerializer class, with an optional third argument of target.

I’m trying to get the types updated to reflect this over at DefinitelyTyped, but the docs don’t reflect the definition in the code.

Is it the intention that consumers use the target argument, or is this omitted from the documentation for the purposes of preventing people from using it externally? What’s the process on updating the docs?

Stuff that shows up in the code but not in the declared types, except when obviously incorrect, is often intended to be private. It looks like that’s the case here too. Did you run into a situation where the extra argument would be useful for external code, or just notice the discrepancy?

Yeah we have a use case for providing a target (Node) to stick the output into, specifically for rendering to PDF, or to a canvas. It works as-is (passing target) - we just have to ignore the compiler warnings for that line. If this isn’t the intended use-case, though, we can find another way.

I’d recommend to just let it build up a fragment and append that to your target node.

1 Like

Makes sense. Thanks