Skip to content

Commit de6ed66

Browse files
stee-reca-d
authored andcommitted
fix: isSetAttribute to allow attr OR attrNS
1 parent f5a7682 commit de6ed66

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

editv2.spec.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,12 @@ const element = new DOMParser().parseFromString(
1414
'application/xml',
1515
)!.documentElement;
1616

17-
const update: Update = { element, attributes: {} };
17+
const update: Update = {
18+
element,
19+
attributes: {
20+
attr1: { namespaceURI: 'http://myns.com', value: 'new value' },
21+
},
22+
};
1823
const insert: Insert = { parent: element, node: element, reference: null };
1924
const remove: Remove = { node: element };
2025
const setAttributes: SetAttributes = {

editv2.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,11 @@ export function isRemove(edit: unknown): edit is Remove {
8181
}
8282

8383
export function isSetAttributes(edit: unknown): edit is SetAttributes {
84+
const setAttrs = edit as SetAttributes;
8485
return (
85-
(edit as SetAttributes).element instanceof Element &&
86-
isAttributesV2((edit as SetAttributes).attributes) &&
87-
isAttributesNS((edit as SetAttributes).attributesNS)
86+
setAttrs.element instanceof Element &&
87+
(isAttributesV2(setAttrs.attributes) ||
88+
isAttributesNS(setAttrs.attributesNS))
8889
);
8990
}
9091

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,9 @@
8282
},
8383
"lint-staged": {
8484
"*.ts": [
85-
"eslint --fix --config package.json",
85+
"eslint --fix",
8686
"prettier --write",
87-
"eslint --config package.json"
87+
"eslint"
8888
]
8989
}
9090
}

0 commit comments

Comments
 (0)