Skip to content

Commit bc485af

Browse files
committed
fix: improve LNodeLibrary loading logic
1 parent 5c52e44 commit bc485af

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

packages/compas-open-scd/src/open-scd.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,8 @@ export class OpenSCD extends LitElement {
141141
this.compasApi = {
142142
lNodeLibrary: {
143143
loadLNodeLibrary: async () => {
144-
if (this._lNodeLibrary) return this._lNodeLibrary;
145-
this._lNodeLibrary = await this.loadLNodeLibrary();
146-
return this._lNodeLibrary;
144+
const doc = await this.loadLNodeLibrary();
145+
return doc;
147146
},
148147
lNodeLibrary: () => this._lNodeLibrary,
149148
},
@@ -153,7 +152,11 @@ export class OpenSCD extends LitElement {
153152
private async loadLNodeLibrary(): Promise<Document | null> {
154153
try {
155154
const doc = await CompasSclDataService().getSclDocument(this, 'SSD', LNODE_LIB_DOC_ID);
156-
return doc instanceof Document ? doc : null;
155+
if (doc instanceof Document) {
156+
this._lNodeLibrary = doc;
157+
return doc;
158+
}
159+
return null;
157160
} catch (reason) {
158161
createLogEvent(this, reason);
159162
return null;

0 commit comments

Comments
 (0)