Skip to content

Commit 7fc1ec9

Browse files
ca-dstee-re
authored andcommitted
refactor: consistently mark only V2 in names
1 parent af43dbe commit 7fc1ec9

File tree

5 files changed

+18
-18
lines changed

5 files changed

+18
-18
lines changed

convertEdit.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ import {
77
} from './editv1.js';
88

99
import {
10-
Attributes,
10+
AttributesV2,
1111
AttributesNS,
1212
EditV2,
1313
isInsert,
1414
isRemove,
1515
} from './editv2.js';
1616

1717
function convertUpdate(edit: Update): EditV2 {
18-
const attributes: Attributes = {};
18+
const attributes: AttributesV2 = {};
1919
const attributesNS: AttributesNS = {};
2020

2121
Object.entries(edit.attributes).forEach(([key, value]) => {

editv1.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export type NamespacedAttributeValue = {
77

88
export type AttributeValue = string | null | NamespacedAttributeValue;
99

10-
export type AttributesV1 = Partial<Record<string, AttributeValue>>;
10+
export type Attributes = Partial<Record<string, AttributeValue>>;
1111

1212
/** Intent to set or remove (if null) attributes on element */
1313
export type Update = {
@@ -31,9 +31,7 @@ export function isNamespaced(
3131
);
3232
}
3333

34-
export function isAttributesV1(
35-
attributes: unknown,
36-
): attributes is AttributesV1 {
34+
export function isAttributes(attributes: unknown): attributes is Attributes {
3735
if (attributes === null || typeof attributes !== 'object') {
3836
return false;
3937
}
@@ -52,7 +50,7 @@ export function isComplexEdit(edit: unknown): edit is Edit[] {
5250
export function isUpdate(edit: unknown): edit is Update {
5351
return (
5452
(edit as Update).element instanceof Element &&
55-
isAttributesV1((edit as Update).attributes)
53+
isAttributes((edit as Update).attributes)
5654
);
5755
}
5856

editv2.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,16 @@ export type SetTextContent = {
1717
};
1818

1919
/** Record from attribute names to attribute values */
20-
export type Attributes = Partial<Record<string, string | null>>;
20+
export type AttributesV2 = Partial<Record<string, string | null>>;
2121

2222
/** Record from namespace URIs to `Attributes` records */
23-
export type AttributesNS = Partial<Record<string, Attributes>>;
23+
export type AttributesNS = Partial<Record<string, AttributesV2>>;
2424

2525
/** Intent to set or remove (if `null`) `attributes`(-`NS`) on `element` */
2626
export type SetAttributes = {
2727
element: Element;
28-
attributes: Attributes;
29-
attributesNS: AttributesNS;
28+
attributes?: AttributesV2;
29+
attributesNS?: AttributesNS;
3030
};
3131

3232
/** Intent to change some XMLDocuments */
@@ -37,7 +37,9 @@ export type EditV2 =
3737
| Remove
3838
| EditV2[];
3939

40-
export function isAttributes(attributes: unknown): attributes is Attributes {
40+
export function isAttributesV2(
41+
attributes: unknown,
42+
): attributes is AttributesV2 {
4143
if (typeof attributes !== 'object' || attributes === null) {
4244
return false;
4345
}
@@ -56,7 +58,7 @@ export function isAttributesNS(
5658
return Object.entries(attributesNS).every(
5759
([namespace, attributes]) =>
5860
typeof namespace === 'string' &&
59-
isAttributes(attributes as Record<string, string | null>),
61+
isAttributesV2(attributes as Record<string, string | null>),
6062
);
6163
}
6264

@@ -81,7 +83,7 @@ export function isRemove(edit: unknown): edit is Remove {
8183
export function isSetAttributes(edit: unknown): edit is SetAttributes {
8284
return (
8385
(edit as SetAttributes).element instanceof Element &&
84-
isAttributes((edit as SetAttributes).attributes) &&
86+
isAttributesV2((edit as SetAttributes).attributes) &&
8587
isAttributesNS((edit as SetAttributes).attributesNS)
8688
);
8789
}

oscd-api.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export type {
2-
Attributes,
2+
AttributesV2,
33
AttributesNS,
44
EditV2,
55
Insert,
@@ -9,7 +9,7 @@ export type {
99
} from './editv2.js';
1010

1111
export type {
12-
AttributesV1,
12+
Attributes,
1313
AttributeValue,
1414
Edit,
1515
NamespacedAttributeValue,

utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export {
2-
isAttributes,
2+
isAttributesV2,
33
isAttributesNS,
44
isComplexEditV2,
55
isEditV2,
@@ -10,7 +10,7 @@ export {
1010
} from './editv2.js';
1111

1212
export {
13-
isAttributesV1,
13+
isAttributes,
1414
isComplexEdit,
1515
isEdit,
1616
isNamespaced,

0 commit comments

Comments
 (0)