DmitryBaranovskiy/raphael — Issue #426: Javascript error when create a canvas with null argument
Author: vickvu
Created: 2011-10-21 05:15:31+00:00
State: open

When user try to create a canvas object with null argument, for example
r = Rapahel(null, "100%", "100%");
or
r = Rapahel("noSuchId", "100%", "100%"); //There is no element with id "noSuchId"

the javascript will throw an exception that some variable is undefined.
The problem is this code at line 4332
var con = R._getContainer.apply(0, arguments),
container = con && con.container,
x = con.x,
y = con.y,
width = con.width,
height = con.height;
if (!container) {
throw new Error("SVG container not found.");
}

It should better be:

var con = R._getContainer.apply(0, arguments);
container = con && con.container;
if (!container) {
throw new Error("SVG container not found.");
}
x = con.x;
y = con.y;
width = con.width;
height = con.height;

so the proper error is thrown