Skip to content

Commit 757648e

Browse files
author
Dennis Labordus
committed
Make the load method more stable, to first check if all the needed data is there.
Signed-off-by: Dennis Labordus <[email protected]>
1 parent 3cded3d commit 757648e

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

src/Logging.ts

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -149,20 +149,21 @@ export function Logging<TBase extends LitElementConstructor>(Base: TBase) {
149149
}
150150

151151
private async onLoadHistoryFromDoc(event: OpenDocEvent) {
152-
const doc = event.detail.doc;
153-
154-
Array.from(
155-
doc.querySelectorAll(':root > Header > History > Hitem')
156-
).forEach(historyItem => {
157-
this.history.push(
158-
this.createSclHistoryEntry(
159-
historyItem.getAttribute('who'),
160-
historyItem.getAttribute('what'),
161-
historyItem.getAttribute('why'),
162-
historyItem.getAttribute('when')
163-
)
164-
);
165-
});
152+
if (event.detail && event.detail.doc) {
153+
const doc = event.detail.doc;
154+
Array.from(
155+
doc.querySelectorAll(':root > Header > History > Hitem')
156+
).forEach(historyItem => {
157+
this.history.push(
158+
this.createSclHistoryEntry(
159+
historyItem.getAttribute('who'),
160+
historyItem.getAttribute('what'),
161+
historyItem.getAttribute('why'),
162+
historyItem.getAttribute('when')
163+
)
164+
);
165+
});
166+
}
166167
}
167168

168169
private onIssue(de: IssueEvent): void {

0 commit comments

Comments
 (0)