Issue with nested decorations

I am building a kinf of linter. I can have errors containing other errors. I am hence using nested decorations. Each decoration has its own CSS class and also contain a data-error giving mode details about the error. While the CSS class is properly assigned, the data-error is not set on nested decoration.

Is-it an issue on ProseMirror or in my side?

Code example:

  results.forEach(issue => {
    decorations.push(Decoration.inline(issue.from, issue.to, {
      class: 'problem ' + issue.classes,
      ['data-error']: issue.message
    })
    )
  })

  return DecorationSet.create(doc, decorations)

I think the attributes are merged, since when multiple inline decorations apply to a given bit of content, they are combined, and since the library doesn’t know how to union any attributes other than class and style, it’ll just pick one value if more than one is provided.

Thanks @marijn for your answer. How could I change this to have the same behavior with data than with class and style?

You can’t, really. That’s not configurable at the moment, and doesn’t seem like a very obvious thing to add. Are you using these for some kind of tooltip? Would it work to store the messages elsewhere and have the tooltip read them from there?

Yes for tooltips. What do you have in mind by “elsewhere”?

The best way is probably a plugin state field, which tracks the ranges (or even uses the DecorationSet to do so by adding an additional property to your decoration spec objects, using the find method to find decorations at a given position, and combining their messages somehow.