Skip to content

Commit 41e3783

Browse files
committed
chore(shape): validate position params
1 parent 18f42d9 commit 41e3783

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/helper/modify-shape-helper.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,19 +44,28 @@ export default class ModifyShapeHelper {
4444
): void => {
4545
const map = {
4646
x: { tag: 'a:off', attribute: 'x' },
47+
l: { tag: 'a:off', attribute: 'x' },
48+
left: { tag: 'a:off', attribute: 'x' },
4749
y: { tag: 'a:off', attribute: 'y' },
48-
w: { tag: 'a:ext', attribute: 'cx' },
49-
h: { tag: 'a:ext', attribute: 'cy' },
50+
t: { tag: 'a:off', attribute: 'y' },
51+
top: { tag: 'a:off', attribute: 'y' },
5052
cx: { tag: 'a:ext', attribute: 'cx' },
53+
w: { tag: 'a:ext', attribute: 'cx' },
54+
width: { tag: 'a:ext', attribute: 'cx' },
5155
cy: { tag: 'a:ext', attribute: 'cy' },
56+
h: { tag: 'a:ext', attribute: 'cy' },
57+
height: { tag: 'a:ext', attribute: 'cy' },
5258
};
5359

5460
const xfrm = element.getElementsByTagName('a:off')[0].parentNode as Element;
5561

5662
Object.keys(pos).forEach((key) => {
63+
const value = Math.round(pos[key]);
64+
if(typeof value !== 'number') return;
65+
5766
xfrm
5867
.getElementsByTagName(map[key].tag)[0]
59-
.setAttribute(map[key].attribute, Math.round(pos[key]));
68+
.setAttribute(map[key].attribute, value);
6069
});
6170
};
6271
}

0 commit comments

Comments
 (0)