Why parseDOM is not a strict rule?

Example code:

  const mySchema = new Schema({
    nodes: {
      doc: {
        content: "foo*"
      },
      foo: {
        content: "text*",
        parseDOM: [{tag: "p"}]
      },
      text: {},
    },
  });

  const element = document.createElement('div');
  element.innerHTML = '<div>Hello World!</div>';
  const myDoc = DOMParser.fromSchema(mySchema).parse(element);
  console.log(myDoc.toString()); // ❓ doc(foo("Hello World!"))

As you can see, the HTML which we pass to parser is <div>Hello World</div> but foo node require p HTML tag. So why we are still parse such document as doc(foo(...)) ignoring parse rule. I would rather expect that parser returns empty document doc() but maybe my conceptual model is wrong. Would glad to hear why it behaves like it’s now.

Thanks

The DOM parser will create parent nodes for content that it parses when it doesn’t fit directly in the current context. In this case, it finds the text, and creates a foo node to hold it.