@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.
- package/js/tables/html.js +10 -3
- 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
|
-
|
|
102
|
+
const parts = [];
|
|
103
|
+
let position = 0;
|
|
104
|
+
replacements
|
|
103
105
|
.slice()
|
|
104
|
-
.sort((first, second) =>
|
|
105
|
-
.
|
|
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;
|