Skip to content

Commit 5476bd0

Browse files
authored
fix: change pattern definition of tIDNaming to non-whitespace characters (openscd#1670)
* fix: update nmToken regex to match non-whitespace characters Signed-off-by: Nora Blomaard <[email protected]> * fix: replace hardcoded regex pattern with patterns.nmToken in wizard tests Signed-off-by: Nora Blomaard <[email protected]> --------- Signed-off-by: Nora Blomaard <[email protected]>
1 parent f9f5e45 commit 5476bd0

File tree

5 files changed

+7
-41
lines changed

5 files changed

+7
-41
lines changed

packages/openscd/src/foundation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2348,7 +2348,7 @@ const nameStartChar =
23482348
const nameChar =
23492349
nameStartChar + '|[.0-9\\-]|\u00B7|[\u0300-\u036F]|[\u203F-\u2040]';
23502350
const name = nameStartChar + '(' + nameChar + ')*';
2351-
const nmToken = '(' + nameChar + ')+';
2351+
const nmToken = '\\S+';
23522352

23532353
export const patterns = {
23542354
string:

packages/plugins/test/integration/editors/templates/datype-wizarding.test.ts

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,7 @@ describe('DAType wizards', () => {
7373
});
7474
});
7575

76-
//work around, because the escapes get removed in snapshot
7776
it('should have correct pattern', async () => {
78-
const pattern =
79-
'([:_A-Za-z]|[\u00C0-\u00D6]|[\u00D8-\u00F6]|[\u00F8-\u02FF]|[\u0370-\u037D]' +
80-
'|[\u037F-\u1FFF]|[\u200C-\u200D]|[\u2070-\u218F]|[\u2C00-\u2FEF]' +
81-
'|[\u3001-\uD7FF]|[\uF900-\uFDCF]|[\uFDF0-\uFFFD]|[.0-9\\-]|\u00B7|[\u0300-\u036F]|[\u203F-\u2040])+';
8277
expect(
8378
parent.wizardUI.dialog!.querySelectorAll('wizard-textfield[pattern]')!
8479
.length
@@ -88,7 +83,7 @@ describe('DAType wizards', () => {
8883
parent.wizardUI
8984
.dialog!.querySelectorAll('wizard-textfield[pattern]')[0]
9085
.getAttribute('pattern')
91-
).to.equal(pattern);
86+
).to.equal(patterns.nmToken);
9287

9388
expect(
9489
parent.wizardUI
@@ -180,12 +175,7 @@ describe('DAType wizards', () => {
180175
});
181176
});
182177

183-
//work around, because the escapes get removed in snapshot
184178
it('should have correct pattern', async () => {
185-
const pattern =
186-
'([:_A-Za-z]|[\u00C0-\u00D6]|[\u00D8-\u00F6]|[\u00F8-\u02FF]|[\u0370-\u037D]' +
187-
'|[\u037F-\u1FFF]|[\u200C-\u200D]|[\u2070-\u218F]|[\u2C00-\u2FEF]' +
188-
'|[\u3001-\uD7FF]|[\uF900-\uFDCF]|[\uFDF0-\uFFFD]|[.0-9\\-]|\u00B7|[\u0300-\u036F]|[\u203F-\u2040])+';
189179
expect(
190180
parent.wizardUI.dialog!.querySelectorAll('wizard-textfield[pattern]')!
191181
.length
@@ -195,7 +185,7 @@ describe('DAType wizards', () => {
195185
parent.wizardUI
196186
.dialog!.querySelectorAll('wizard-textfield[pattern]')[0]
197187
.getAttribute('pattern')
198-
).to.equal(pattern);
188+
).to.equal(patterns.nmToken);
199189

200190
expect(
201191
parent.wizardUI

packages/plugins/test/integration/editors/templates/dotype-wizarding.test.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ describe('DOType wizards', () => {
8282
});
8383
});
8484

85-
// work around, because the escapes get removed in snapshot by prettier
8685
it('should have correct pattern', async () => {
8786
expect(
8887
parent.wizardUI.dialog!.querySelectorAll('wizard-textfield[pattern]')!
@@ -218,7 +217,6 @@ describe('DOType wizards', () => {
218217
});
219218
});
220219

221-
// work around, because the escapes get removed in snapshot by prettier
222220
it('should have correct pattern', async () => {
223221
expect(
224222
parent.wizardUI.dialog!.querySelectorAll('wizard-textfield[pattern]')!
@@ -323,7 +321,6 @@ describe('DOType wizards', () => {
323321
});
324322
});
325323

326-
// work around, because the escapes get removed in snapshot by prettier
327324
it('should have correct pattern', async () => {
328325
expect(
329326
parent.wizardUI.dialog!.querySelectorAll('wizard-textfield[pattern]')!
@@ -440,7 +437,6 @@ describe('DOType wizards', () => {
440437
});
441438
});
442439

443-
// work around, because the escapes get removed in snapshot by prettier
444440
it('should have correct pattern', async () => {
445441
expect(
446442
parent.wizardUI.dialog!.querySelectorAll('wizard-textfield[pattern]')!

packages/plugins/test/integration/editors/templates/enumtype-wizarding.test.ts

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,7 @@ describe('EnumType wizards', () => {
7373
});
7474
});
7575

76-
//work around, because the escapes get removed in snapshot
7776
it('should have correct pattern', async () => {
78-
const pattern =
79-
'([:_A-Za-z]|[\u00C0-\u00D6]|[\u00D8-\u00F6]|[\u00F8-\u02FF]|[\u0370-\u037D]' +
80-
'|[\u037F-\u1FFF]|[\u200C-\u200D]|[\u2070-\u218F]|[\u2C00-\u2FEF]' +
81-
'|[\u3001-\uD7FF]|[\uF900-\uFDCF]|[\uFDF0-\uFFFD]|[.0-9\\-]|\u00B7|[\u0300-\u036F]|[\u203F-\u2040])+';
8277
expect(
8378
parent.wizardUI.dialog!.querySelectorAll('wizard-textfield[pattern]')!
8479
.length
@@ -88,7 +83,7 @@ describe('EnumType wizards', () => {
8883
parent.wizardUI
8984
.dialog!.querySelectorAll('wizard-textfield[pattern]')[0]
9085
.getAttribute('pattern')
91-
).to.equal(pattern);
86+
).to.equal(patterns.nmToken);
9287

9388
expect(
9489
parent.wizardUI
@@ -167,12 +162,7 @@ describe('EnumType wizards', () => {
167162
});
168163
});
169164

170-
//work around, because the escapes get removed in snapshot
171165
it('should have correct pattern', async () => {
172-
const pattern =
173-
'([:_A-Za-z]|[\u00C0-\u00D6]|[\u00D8-\u00F6]|[\u00F8-\u02FF]|[\u0370-\u037D]' +
174-
'|[\u037F-\u1FFF]|[\u200C-\u200D]|[\u2070-\u218F]|[\u2C00-\u2FEF]' +
175-
'|[\u3001-\uD7FF]|[\uF900-\uFDCF]|[\uFDF0-\uFFFD]|[.0-9\\-]|\u00B7|[\u0300-\u036F]|[\u203F-\u2040])+';
176166
expect(
177167
parent.wizardUI.dialog!.querySelectorAll('wizard-textfield[pattern]')!
178168
.length
@@ -182,7 +172,7 @@ describe('EnumType wizards', () => {
182172
parent.wizardUI
183173
.dialog!.querySelectorAll('wizard-textfield[pattern]')[0]
184174
.getAttribute('pattern')
185-
).to.equal(pattern);
175+
).to.equal(patterns.nmToken);
186176

187177
expect(
188178
parent.wizardUI

packages/plugins/test/integration/editors/templates/lnodetype-wizard.test.ts

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,7 @@ describe('LNodeType wizards', () => {
7373
});
7474
});
7575

76-
//work around, because the escapes get removed in snapshot
7776
it('should have correct pattern', async () => {
78-
const pattern =
79-
'([:_A-Za-z]|[\u00C0-\u00D6]|[\u00D8-\u00F6]|[\u00F8-\u02FF]|[\u0370-\u037D]' +
80-
'|[\u037F-\u1FFF]|[\u200C-\u200D]|[\u2070-\u218F]|[\u2C00-\u2FEF]' +
81-
'|[\u3001-\uD7FF]|[\uF900-\uFDCF]|[\uFDF0-\uFFFD]|[.0-9\\-]|\u00B7|[\u0300-\u036F]|[\u203F-\u2040])+';
8277
expect(
8378
parent.wizardUI.dialog!.querySelectorAll('wizard-textfield[pattern]')!
8479
.length
@@ -88,7 +83,7 @@ describe('LNodeType wizards', () => {
8883
parent.wizardUI
8984
.dialog!.querySelectorAll('wizard-textfield[pattern]')[0]
9085
.getAttribute('pattern')
91-
).to.equal(pattern);
86+
).to.equal(patterns.nmToken);
9287

9388
expect(
9489
parent.wizardUI
@@ -169,12 +164,7 @@ describe('LNodeType wizards', () => {
169164
});
170165
});
171166

172-
//work around, because the escapes get removed in snapshot
173167
it('should have correct pattern', async () => {
174-
const pattern =
175-
'([:_A-Za-z]|[\u00C0-\u00D6]|[\u00D8-\u00F6]|[\u00F8-\u02FF]|[\u0370-\u037D]' +
176-
'|[\u037F-\u1FFF]|[\u200C-\u200D]|[\u2070-\u218F]|[\u2C00-\u2FEF]' +
177-
'|[\u3001-\uD7FF]|[\uF900-\uFDCF]|[\uFDF0-\uFFFD]|[.0-9\\-]|\u00B7|[\u0300-\u036F]|[\u203F-\u2040])+';
178168
expect(
179169
parent.wizardUI.dialog!.querySelectorAll('wizard-textfield[pattern]')!
180170
.length
@@ -184,7 +174,7 @@ describe('LNodeType wizards', () => {
184174
parent.wizardUI
185175
.dialog!.querySelectorAll('wizard-textfield[pattern]')[0]
186176
.getAttribute('pattern')
187-
).to.equal(pattern);
177+
).to.equal(patterns.nmToken);
188178

189179
expect(
190180
parent.wizardUI

0 commit comments

Comments
 (0)