Throw errors directly, rather than using assert
, in the DOMSVGFactory
This is similar to all of the other factories in this file, since they *directly* throw errors.
This commit is contained in:
parent
26011c65f4
commit
3bd24d8d5a
@ -118,8 +118,9 @@ class DOMStandardFontDataFactory extends BaseStandardFontDataFactory {
|
|||||||
|
|
||||||
class DOMSVGFactory {
|
class DOMSVGFactory {
|
||||||
create(width, height) {
|
create(width, height) {
|
||||||
assert(width > 0 && height > 0, "Invalid SVG dimensions");
|
if (width <= 0 || height <= 0) {
|
||||||
|
throw new Error("Invalid SVG dimensions");
|
||||||
|
}
|
||||||
const svg = document.createElementNS(SVG_NS, "svg:svg");
|
const svg = document.createElementNS(SVG_NS, "svg:svg");
|
||||||
svg.setAttribute("version", "1.1");
|
svg.setAttribute("version", "1.1");
|
||||||
svg.setAttribute("width", width + "px");
|
svg.setAttribute("width", width + "px");
|
||||||
@ -131,8 +132,9 @@ class DOMSVGFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
createElement(type) {
|
createElement(type) {
|
||||||
assert(typeof type === "string", "Invalid SVG element type");
|
if (typeof type !== "string") {
|
||||||
|
throw new Error("Invalid SVG element type");
|
||||||
|
}
|
||||||
return document.createElementNS(SVG_NS, type);
|
return document.createElementNS(SVG_NS, type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user