Skip to content

Commit a40c701

Browse files
stee-reca-d
authored andcommitted
feat: stateVersion should be docVersion
Resolves: #71
1 parent 62e21d3 commit a40c701

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

oscd-shell.spec.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -153,15 +153,15 @@ describe('with editor plugins loaded', () => {
153153
});
154154
});
155155

156-
it('passes property stateVersion', async () => {
156+
it('passes property docVersion', async () => {
157157
editor.dispatchEvent(newOpenEvent(doc, 'test.scd'));
158158
await editor.updateComplete;
159159

160-
expect(editorPlugin.stateVersion).to.equal(0);
160+
expect(editorPlugin.docVersion).to.equal(0);
161161
expect(editorPlugin.editCount).to.equal(0);
162162
});
163163

164-
it('updated passed stateVersion property on edit events', async () => {
164+
it('updated passed docVersion property on edit events', async () => {
165165
editor.dispatchEvent(newOpenEvent(doc, 'test.scd'));
166166
await editor.updateComplete;
167167

@@ -174,7 +174,7 @@ describe('with editor plugins loaded', () => {
174174
);
175175
await editor.updateComplete;
176176

177-
expect(editorPlugin.stateVersion).to.equal(1);
177+
expect(editorPlugin.docVersion).to.equal(1);
178178
expect(editorPlugin.editCount).to.equal(1);
179179
});
180180
});
@@ -239,15 +239,15 @@ describe('with menu plugins loaded', () => {
239239
});
240240
});
241241

242-
it('passes property stateVersion', async () => {
242+
it('passes property docVersion', async () => {
243243
editor.dispatchEvent(newOpenEvent(doc, 'test.scd'));
244244
await editor.updateComplete;
245245

246-
expect(menuPlugin).to.have.property('stateVersion', 0);
246+
expect(menuPlugin).to.have.property('docVersion', 0);
247247
expect(menuPlugin).to.have.property('editCount', 0);
248248
});
249249

250-
it('updated passed stateVersion property on edit events', async () => {
250+
it('updated passed docVersion property on edit events', async () => {
251251
editor.dispatchEvent(newOpenEvent(doc, 'test.scd'));
252252
await editor.updateComplete;
253253

@@ -260,7 +260,7 @@ describe('with menu plugins loaded', () => {
260260
);
261261
await editor.updateComplete;
262262

263-
expect(menuPlugin).to.have.property('stateVersion', 1);
263+
expect(menuPlugin).to.have.property('docVersion', 1);
264264
expect(menuPlugin).to.have.property('editCount', 1);
265265
});
266266
});

oscd-shell.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ export interface Plugin {
5151
docs: Record<string, XMLDocument>;
5252
doc?: XMLDocument; // the document currently being edited
5353
docName?: string; // the current doc's name
54-
stateVersion: unknown; // changes when the document is modified
55-
/** @deprecated Use `stateVersion` instead */
54+
docVersion: unknown; // changes when the document is modified
55+
/** @deprecated Use `docVersion` instead */
5656
editCount: number; // the number of edits made to the document
5757
locale: string; // the end user's chosen locale
5858
}
@@ -160,7 +160,7 @@ export class OpenSCD extends LitElement {
160160
}
161161

162162
onDocsChanged() {
163-
this.stateVersion += 1;
163+
this.docVersion += 1;
164164
}
165165

166166
/** The name of the [[`doc`]] currently being edited */
@@ -176,7 +176,7 @@ export class OpenSCD extends LitElement {
176176
xmlEditor: XMLEditor = new XMLEditor();
177177

178178
@state()
179-
stateVersion: number = -1;
179+
docVersion: number = -1;
180180

181181
@state()
182182
get last(): number {
@@ -400,7 +400,7 @@ export class OpenSCD extends LitElement {
400400

401401
// Catch all edits (from commits AND events) and trigger an update
402402
this.xmlEditor.subscribe(() => {
403-
this.stateVersion += 1;
403+
this.docVersion += 1;
404404
});
405405
}
406406

@@ -423,8 +423,8 @@ export class OpenSCD extends LitElement {
423423
.docName="${this.docName}"
424424
.doc=${this.doc}
425425
.docs=${this.docs}
426-
.editCount=${this.stateVersion}
427-
.stateVersion=${this.stateVersion}
426+
.editCount=${this.docVersion}
427+
.docVersion=${this.docVersion}
428428
.editor=${this.xmlEditor}>
429429
</${tag}>`;
430430
}

0 commit comments

Comments
 (0)