prismicio/javascript-kit — pull request #54 by rudyrigot (2014-06-19 19:00:45+00:00)
Title: Zero-length and negative spans are now removed in submit()

There is a bug in the API that returns wrong spans in structured text fragments, with start == end, or start > end, like that:

```
spans: [
{
start: 43,
end: 43,
type: "strong"
},
{
start: 102,
end: 43,
type: "strong"
}
]
```

Up till now, the kit was working around the bug by discarding those spans in `asHtml()`; but this only works if `asHtml()` is what you want to do with your structured text. For any other manipulation, you still have those spans hanging around.
This PR removes the workaround in `asHtml` that passively discards those spans, and introduces another workaround, in `submit()` this time, that actively suppresses those spans before documents are returned. This effectively make all structured text fragments clean from wrong spans, before any manipulation gets done.