Skip to content

Commit 3dda9b2

Browse files
committed
either sonar or ts complains. manage both.
1 parent 70385fb commit 3dda9b2

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

webapp/src/ts/services/enketo.service.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -365,12 +365,14 @@ export class EnketoService {
365365
if ($id.length) {
366366
id = $id.text();
367367
}
368-
id ??= uuid();
368+
if (!id) {
369+
id = uuid();
370+
}
369371
}
370372
e._couchId = id;
371373
};
372374

373-
mapOrAssignId($record[0], doc._id ?? uuid());
375+
mapOrAssignId($record[0], doc._id || uuid());
374376

375377
const getId = (xpath) => {
376378
const xPathResult = recordDoc.evaluate(xpath, recordDoc, null, XPathResult.ANY_TYPE, null);
@@ -411,7 +413,9 @@ export class EnketoService {
411413
}
412414

413415
// assign a unique id for xpath context, since the element can be inside a repeat
414-
element.id ??= uuid();
416+
if (!element.id) {
417+
element.id = uuid();
418+
}
415419
const uniqueElementSelector = `${element.nodeName}[@id="${element.id}"]`;
416420

417421
const closestPath = `//${uniqueElementSelector}/ancestor-or-self::*/descendant-or-self::${relativePath}`;

webapp/tests/karma/ts/services/enketo.service.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { ExtractLineageService } from '@mm-services/extract-lineage.service';
1414
import * as FileManager from '../../../../src/js/enketo/file-manager.js';
1515
import { WebappEnketoFormContext } from '@mm-services/form.service';
1616

17-
describe('Enketo service', () => {
17+
describe.only('Enketo service', () => {
1818
// return a mock form ready for putting in #dbContent
1919
const mockEnketoDoc = formInternalId => {
2020
return {

0 commit comments

Comments
 (0)