Hi, I fail to fully understand the behaviour of “attrs” in a “parseDOM”, here are 2 examples:
-
parseDOM: [{tag: "span", attrs: {"class":"foobar"}]
: here, all “span” elements will be matched, and their class will become “foobar”. -
parseDOM: [{ attrs: { "class": "foobar" }}]
: here only elements with the class “foobar” will be matched
Do I understand correctly?
It seems to me that “attrs” does not behave as a matcher if there is already another matcher like “tag” (case 1). Instead, you should use getAttrs
to both filter the elements you want, so only “span” with the “foobar” class), + select the attributes you want if the element matches.
However, it does behave as a matcher if its alone (case 2).
Is there something I am missing?
Side-question: in 1), what’s the effect of setting {“class”: “foobar”} specifically? It means we forget the element class and replace it by “foobar”?
Reference: ProseMirror Reference manual (it’s quite terse on “attrs”, “getAttrs” is clearer though)