@matrixreq/htmldiff 2.0.0 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/js/tables/html.js +10 -3
  2. package/package.json +1 -1
package/js/tables/html.js CHANGED
@@ -99,9 +99,16 @@ function decodeEntities(text) {
99
99
  }
100
100
  exports.decodeEntities = decodeEntities;
101
101
  function replaceRanges(html, replacements) {
102
- return replacements
102
+ const parts = [];
103
+ let position = 0;
104
+ replacements
103
105
  .slice()
104
- .sort((first, second) => second.start - first.start)
105
- .reduce((result, replacement) => result.slice(0, replacement.start) + replacement.html + result.slice(replacement.end), html);
106
+ .sort((first, second) => first.start - second.start)
107
+ .forEach((replacement) => {
108
+ parts.push(html.slice(position, replacement.start), replacement.html);
109
+ position = replacement.end;
110
+ });
111
+ parts.push(html.slice(position));
112
+ return parts.join("");
106
113
  }
107
114
  exports.replaceRanges = replaceRanges;
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@matrixreq/htmldiff",
3
3
  "description": "Diff and markup HTML with <ins> and <del> tags",
4
4
  "companyname": "Matrix Requirements",
5
- "version": "2.0.0",
5
+ "version": "2.0.1",
6
6
  "keywords": [
7
7
  "diff",
8
8
  "html",