Skip to content

fix: refresh on opening of the same document name #27

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions open-scd.editing.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,22 @@ describe('Editing Element', () => {
expect(editor.docName).to.equal('test.scd');
});

it('refreshes a document with the same name as one already opened on OpenDocEvent', async () => {
editor.dispatchEvent(newOpenEvent(sclDoc, 'test.scd'));
const firstUpdate = editor.updateComplete;
await firstUpdate;
sclDoc = new DOMParser().parseFromString(
util.sclDocString,
'application/xml'
);
editor.dispatchEvent(newOpenEvent(sclDoc, 'test.scd'));
const secondUpdate = editor.updateComplete;
await secondUpdate;
expect(firstUpdate).to.not.equal(secondUpdate);
expect(editor.doc).to.equal(sclDoc);
expect(editor.docName).to.equal('test.scd');
});

it('inserts an element on Insert', () => {
const parent = sclDoc.documentElement;
const node = sclDoc.createElement('test');
Expand Down
1 change: 1 addition & 0 deletions open-scd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ export class OpenSCD extends LitElement {
handleOpenDoc({ detail: { docName, doc } }: OpenEvent) {
this.docName = docName;
this.docs[this.docName] = doc;
this.requestUpdate();
}

updateVersion(): void {
Expand Down
Loading