Parse Issue with `closeParent` option enabled

Hey Community.

I’m having an issue creating a domParser to be used to parse HTML that is produced from a different RTE library (we’re in the process of migrating to prosemirror).

When specific HTML is parsed with the closeParent rule enabled–in this case, specifically for br-tag parsing to close paragraphs–it throws an error.

Smallest repro case is this:

import { DOMParser } from "prosemirror-model";
import { schema } from "prosemirror-schema-basic";

const parser = new DOMParser(schema, [
   { tag: "br", closeParent: true },

const htmlStr = '<p><br></p>';

const element = document.createElement("div");
element.innerHTML = htmlStr;
// errors on this line
const output = parser.parse(element);

Here’s a code-sandbox link to some repro cases, basically anything that contains : practical-newton-cldbcq - CodeSandbox.

I was specifically adding this rule for a similar case as this community post: Paste paragraph containing br

It seems this is a bug, but wanted to check here first. I would think that given properly formatted HTML and valid parse rules, the parser shouldn’t fully error out.

Thanks in advance!

This patch should fix this.

Amazing, thanks for such a quick reply @marijn