Inserting node changes attrs in other nodes

Hi there.

This is a great library, thank you for your work.

I am getting this problem: when I add one of my custom nodes to the document, all the attrs change for all of the other nodes of that kind to the last value input.

What am I doing wrong?

here I insert the node

let nodeToInsert = nodeType.create();
nodeToInsert.attrs.length = attrs.length;
view.dispatch(, true));

and here the node is defined

  break: {
    attrs: {
      type: {default: ""},
      length: {default: 0},
    inline: true,
    group: "inline",
    isText: true,

    toDOM: node => [
        "break-type": node.attrs.type,
        title: node.attrs.type,
        class: "break-tag"
      "" + node.attrs.type + " " + node.attrs.length + " ms "

    parseDOM: [{tag: "break"}]

I would appreciate any help. Thank you

This object is shared, so mutating it is not a good idea. Create a fresh object and pass that to create. As the docs repeatedly warn, do not mutate the library’s immutable objects.

Yes, that fixed my problem.

Thank you, and I must say, while it hasn’t always been very easy using Prose Mirror, it has certainly been instructive.

Just for the record, this is the code.

let nodeToInsert = nodeType.create(new Node());
          nodeToInsert.attrs.length = attrs.length;