From f4e4e7ab9cc2c671dbde7320837409bb3323cb36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Mon, 4 Apr 2016 17:55:43 -0700 Subject: [PATCH] Switch to jsdom v8.3.0, now that it includes our node-canvas PR. See https://github.com/tmpvar/jsdom/pull/1366 --- examples/Node.js/SvgImport.js | 5 ++++- package.json | 2 +- src/node/window.js | 4 ++++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/examples/Node.js/SvgImport.js b/examples/Node.js/SvgImport.js index 6933fd9a..fe7f7fbc 100644 --- a/examples/Node.js/SvgImport.js +++ b/examples/Node.js/SvgImport.js @@ -6,7 +6,7 @@ var path = require('path'); var fs = require('fs'); paper.setup(new paper.Size(300, 600)); -paper.project.importSVG(/*'in.svg'*/'file://' + path.resolve('./in.svg'), { +paper.project.importSVG('file://' + path.resolve('./in.svg'), { onLoad: function(item) { paper.view.exportFrames({ amount: 1, @@ -18,5 +18,8 @@ paper.project.importSVG(/*'in.svg'*/'file://' + path.resolve('./in.svg'), { console.log(event.percentage + '% complete, frame took: ' + event.delta); } }); + }, + onError: function(message) { + console.error(message); } }); diff --git a/package.json b/package.json index 12498b78..cd323d31 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ "node": ">=4.0.0 <6.0.0" }, "dependencies": { - "jsdom": "git://github.com/lehni/jsdom.git#bd86dd16666241edd5f25bc4f4e144f24da3c889", + "jsdom": "^8.3.0", "source-map-support": "^0.4.0" }, "optionalDependencies": { diff --git a/src/node/window.js b/src/node/window.js index ac10fc71..f3700fd1 100644 --- a/src/node/window.js +++ b/src/node/window.js @@ -18,6 +18,10 @@ var jsdom = require('jsdom'); // Create our document and window objects through jsdom. /* global document:true, window:true */ var document = jsdom.jsdom('', { + // Give the resulting document the same origins as the XMLHttpRequest + // objects for local files, so files can be loaded locally without CORS. + // TODO: Find a proper solution instead of this hack. + url: 'file://', features: { FetchExternalResources: ['img', 'script'] }