Skip to content

Commit 26ea5dc

Browse files
author
Kevin Lindsey
committed
Fix for rounded rectangle property parsing
The code now tests if the object being used as a Point2D contains only x and y. If so, then we move to the next item; otherwise, we continue to use the current object for other properties that we’re lookin for.
1 parent 5048dde commit 26ea5dc

8 files changed

+57
-9
lines changed

dist/index-esm.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -3355,8 +3355,11 @@ function parsePoint(names, args) {
33553355
}
33563356
} else if (itemType === "object") {
33573357
if ("x" in item && "y" in item) {
3358-
result = new Point2D(item.x, item.y);
3359-
args.shift();
3358+
result = new Point2D(item.x, item.y); // eslint-disable-next-line compat/compat
3359+
3360+
if (Object.keys(item).length === 2) {
3361+
args.shift();
3362+
}
33603363
} else {
33613364
var _iterator3 = _createForOfIteratorHelper(names),
33623365
_step3;

dist/index-esm.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index-esm.min.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index-umd.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -3361,8 +3361,11 @@
33613361
}
33623362
} else if (itemType === "object") {
33633363
if ("x" in item && "y" in item) {
3364-
result = new Point2D(item.x, item.y);
3365-
args.shift();
3364+
result = new Point2D(item.x, item.y); // eslint-disable-next-line compat/compat
3365+
3366+
if (Object.keys(item).length === 2) {
3367+
args.shift();
3368+
}
33663369
} else {
33673370
var _iterator3 = _createForOfIteratorHelper(names),
33683371
_step3;

dist/index-umd.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index-umd.min.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/ShapeInfo.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,10 @@ export function parsePoint(names, args) {
128128
else if (itemType === "object") {
129129
if ("x" in item && "y" in item) {
130130
result = new Point2D(item.x, item.y);
131-
args.shift();
131+
// eslint-disable-next-line compat/compat
132+
if (Object.keys(item).length === 2) {
133+
args.shift();
134+
}
132135
}
133136
else {
134137
for (const props of names) {

test/shape-info-test.js

+39
Original file line numberDiff line numberDiff line change
@@ -183,4 +183,43 @@ describe("Shapes API", () => {
183183
}
184184
});
185185
});
186+
describe("Rounded Rectangle", () => {
187+
it("Rounded Rectangle - Object 1", () => {
188+
let rr = {
189+
x: 10, y: 20,
190+
width: 30, height: 40,
191+
rx: 3, ry: 4
192+
};
193+
try {
194+
let shape = ShapeInfo.rectangle(rr);
195+
196+
for (let arg of shape.args) {
197+
// TODO: check segments
198+
}
199+
200+
}
201+
catch (e) {
202+
assert.fail("Unable to parse object: " + JSON.stringify(rr));
203+
}
204+
});
205+
it("Rounded Rectangle - Object 2", () => {
206+
let rr = {
207+
x: 10, y: 20,
208+
w: 30, h: 40,
209+
rx: 3, ry: 4
210+
};
211+
try {
212+
let shape = ShapeInfo.rectangle(rr);
213+
214+
for (let arg of shape.args) {
215+
// TODO: check segments
216+
}
217+
218+
}
219+
catch (e) {
220+
assert.fail("Unable to parse object: " + JSON.stringify(rr));
221+
}
222+
223+
});
224+
});
186225
});

0 commit comments

Comments
 (0)