From a prosemirror perspective, that does seem like a bug since the topNode can be something else than "doc". Unsure if item.type works though because item isn’t defined in that context.
Edit: Looks like to resolve this issue, y-prosemirror/lib would have to be modified to use Y.XmlElement instead of Y.XmlFragment since Y.XmlElement defines a nodeName (and allows for top level attrs) and Y.XmlFragment does not.