Skip to content

Commit 27f684e

Browse files
committed
Blah
1 parent 3b0bdf0 commit 27f684e

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

tDataSet/removeDataSet.spec.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,12 @@ describe("Utility function to remove DataSet element", () => {
2121
const val = extRefs[0].ownerDocument.querySelector(
2222
'LN[lnClass="LGOS"][inst="1"] > DOI[name="GoCBRef"] > DAI[name="setSrcRef"] > Val',
2323
)!;
24-
const val2 = extRefs[0].ownerDocument.querySelector(
25-
'LN[lnClass="LGOS"][inst="2"] > DOI[name="GoCBRef"] > DAI[name="setSrcRef"] > Val',
26-
);
24+
const ln = extRefs[0].ownerDocument.querySelector('LN[lnClass="LGOS"][inst="2"]')
2725

2826
it("returns empty string when remove.node is not DataSet", () =>
2927
expect(removeDataSet({ node: val })).to.be.empty);
3028

31-
it("removes DataSet also removes/updates dependant data", () =>
29+
it("removes DataSet also removes/updates dependent data", () =>
3230
expect(edits.length).to.equal(10));
3331

3432
it("including the DataSet itself", () =>
@@ -43,7 +41,7 @@ describe("Utility function to remove DataSet element", () => {
4341

4442
it("including the subscriber supervision", () => {
4543
expect((edits[5] as Remove).node).to.equal(val!.firstChild);
46-
expect((edits[6] as Remove).node).to.equal(val2!.firstChild);
44+
expect((edits[6] as Remove).node).to.equal(ln);
4745
});
4846

4947
it("including control Block updates", () => {

tLN/removeSubscriptionSupervision.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,30 @@ type GroupedExtRefs = {
1010
subscriberIed: Element;
1111
};
1212

13-
/** @returns Element to remove the subscription supervision control block reference */
13+
/** @returns Element to remove the subscription supervision */
1414
function removableSupervisionElement(
1515
ctrlBlock: Element,
1616
subscriberIed: Element,
1717
): Element | null {
1818
const supervisionType = ctrlBlock.tagName === "GSEControl" ? "LGOS" : "LSVS";
19+
const doiName = ctrlBlock.tagName === "GSEControl" ? 'GoCBRef' : 'SvCBRef';
1920

2021
const valElement = Array.from(
2122
subscriberIed.querySelectorAll(
22-
`LN[lnClass="${supervisionType}"] > DOI > DAI > Val`,
23+
`LN[lnClass="${supervisionType}"] > DOI[name="${doiName}"] > DAI[name="setSrcRef"] > Val`,
2324
),
2425
).find((val) => val.textContent === controlBlockObjRef(ctrlBlock));
2526
if (!valElement) return null;
2627

28+
const ln = valElement.closest("LN")!;
29+
const canRemoveLn = ln.querySelector(
30+
':scope > Private[type="OpenSCD.create"]',
31+
);
32+
if (canRemoveLn) return ln;
33+
2734
const textContentNode = Array.from(valElement.childNodes).find(
2835
(child) => child.nodeType === Node.TEXT_NODE,
2936
) as Element;
30-
3137
return textContentNode ?? null;
3238
}
3339

0 commit comments

Comments
 (0)