Navigation Menu

Skip to content

Commit

Permalink
Small bug fix and Node.js test script
Browse files Browse the repository at this point in the history
  • Loading branch information
bpartridge committed Jun 7, 2012
1 parent 0ae7e67 commit d9f2c62
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
3 changes: 3 additions & 0 deletions package.json
Expand Up @@ -9,6 +9,9 @@
"devDependencies": {
"browserify": "1.12.x"
},
"scripts": {
"test": "node test-node.js"
},
"repository": {
"type": "git",
"url": "https://github.com/bpartridge/raphael.git"
Expand Down
8 changes: 7 additions & 1 deletion raphael-browserify.js
Expand Up @@ -4824,7 +4824,13 @@ Raphael.svg && function (R) {
try {
pos = cnvs.getScreenCTM() || cnvs.createSVGMatrix();
} catch (e) {
pos = cnvs.createSVGMatrix();
// BROWSERIFY MOD: this will fail with jsdom since it's SVG 1.0,
// but in jsdom this whole function isn't needed anyways
try {
pos = cnvs.createSVGMatrix();
} catch (e) {
return;
}
}
var left = -pos.e % 1,
top = -pos.f % 1;
Expand Down
16 changes: 16 additions & 0 deletions test-node.js
@@ -0,0 +1,16 @@
Raphael = require('.');
var jsdom = require('jsdom');
var doc = jsdom.jsdom("<html><head></head><body></body></html>");
var win = doc.createWindow();
Raphael.setWindow(win);

paper = Raphael(0, 0, 640, 480);

paper.clear();
paper.text("Hello, world!");
paper.circle(320, 240, 60);

console.log("You should see valid SVG XML here:\n");
console.log(doc.body.firstChild.outerHTML)


0 comments on commit d9f2c62

Please sign in to comment.