Skip to content

Commit 16c541f

Browse files
ca-dstee-re
authored andcommitted
fix(convertEdit): allow '__proto__' attribute name
1 parent 7fc1ec9 commit 16c541f

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

convertEdit.spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ const update: Update = {
2626
attributes: {
2727
name: 'A2',
2828
desc: null,
29+
['__proto__']: 'a string',
2930
'myns:attr': {
3031
value: 'value1',
3132
namespaceURI: 'http://example.org/myns',
@@ -54,6 +55,7 @@ const setAttributes: SetAttributes = {
5455
attributes: {
5556
name: 'A2',
5657
desc: null,
58+
['__proto__']: 'a string',
5759
},
5860
attributesNS: {
5961
'http://example.org/myns': {

convertEdit.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515
} from './editv2.js';
1616

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

2121
Object.entries(edit.attributes).forEach(([key, value]) => {
@@ -28,9 +28,9 @@ function convertUpdate(edit: Update): EditV2 {
2828
if (!attributesNS[ns]) {
2929
attributesNS[ns] = {};
3030
}
31-
attributesNS[ns][key] = value.value;
31+
attributesNS[ns] = { ...attributesNS[ns], [key]: value.value };
3232
} else {
33-
attributes[key] = value;
33+
attributes = { ...attributes, [key]: value };
3434
}
3535
});
3636

0 commit comments

Comments
 (0)