Deleting the last character of a list item creates new list item

Lol, Okay. Just to summarize it has a plugin that adds unique id to following nodes:

[ “paragraph”, “heading”, “table”, “blockquote”, “bulletList”, “orderedList”, “tableRow”, “listItem”, ]

It uses tr.setNodeAttributes to do so. Is there any better way to do this?