word-aligner 1.1.1-beta.2 → 1.1.1-beta.3

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/lib/js/aligner.js CHANGED
@@ -111,7 +111,7 @@ function cleanChildReferences(verseObject) {
111
111
  for (var j = 0, cLen = children.length; j < cLen; j++) {
112
112
  var child = children[j];
113
113
  var childKeyValue = child[key];
114
- if (childKeyValue >= 0) {
114
+ if (childKeyValue !== undefined) {
115
115
  delete child[key];
116
116
  }
117
117
  if (child.children) {
@@ -227,6 +227,10 @@ var merge = exports.merge = function merge(alignments, wordBank, verseString) {
227
227
  var index = VerseObjectUtils.indexOfVerseObject(wordMap, _verseObject4);
228
228
  if (index > -1) {
229
229
  var location = wordMap[index];
230
+ var originalVerseObject = location.array[location.pos];
231
+ if (originalVerseObject.parentIndex !== undefined) {
232
+ _verseObject4.parentIndex = originalVerseObject.parentIndex;
233
+ }
230
234
  location.array[location.pos] = _verseObject4;
231
235
  } else if (hasAlignments(alignments)) {
232
236
  // if verse has some alignments
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "word-aligner",
3
- "version": "1.1.1-beta.2",
3
+ "version": "1.1.1-beta.3",
4
4
  "description": "A library for handling word alignment",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
package/src/js/aligner.js CHANGED
@@ -73,7 +73,7 @@ function cleanChildReferences(verseObject, key = 'parentIndex') {
73
73
  for (let j = 0, cLen = children.length; j < cLen; j++) {
74
74
  const child = children[j];
75
75
  const childKeyValue = child[key];
76
- if (childKeyValue >= 0) {
76
+ if (childKeyValue !== undefined) {
77
77
  delete child[key];
78
78
  }
79
79
  if (child.children) {
@@ -177,6 +177,10 @@ export const merge = (alignments, wordBank, verseString,
177
177
  wordMap, verseObject);
178
178
  if (index > -1) {
179
179
  const location = wordMap[index];
180
+ const originalVerseObject = location.array[location.pos];
181
+ if (originalVerseObject.parentIndex !== undefined) {
182
+ verseObject.parentIndex = originalVerseObject.parentIndex;
183
+ }
180
184
  location.array[location.pos] = verseObject;
181
185
  } else if (hasAlignments(alignments)) { // if verse has some alignments
182
186
  throw {message: `Word "${bottomWord.word}" is in wordBank, but missing from target language verse.`, type: 'InvalidatedAlignments'};