mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-01 02:38:43 -05:00
Make sure PDF support actually works.
This commit is contained in:
parent
1e649362bd
commit
414742459d
2 changed files with 6 additions and 4 deletions
|
@ -13,6 +13,5 @@ fs.readFile('./in.json', { encoding: 'utf8' }, function (err, data) {
|
||||||
if (err)
|
if (err)
|
||||||
throw err;
|
throw err;
|
||||||
console.log('Saved!');
|
console.log('Saved!');
|
||||||
process.exit();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -22,13 +22,17 @@ module.exports = function(window) {
|
||||||
var HTMLCanvasElement = window.HTMLCanvasElement;
|
var HTMLCanvasElement = window.HTMLCanvasElement;
|
||||||
|
|
||||||
function getImplementation(obj) {
|
function getImplementation(obj) {
|
||||||
return obj._canvas ? obj : idlUtils.implForWrapper(obj);
|
// Try implForWrapper() first, fall back on obj. This appears to be
|
||||||
|
// necessary on v7.2.2, but not anymore once we can switch to 8.0.0
|
||||||
|
var impl = idlUtils.implForWrapper(obj);
|
||||||
|
return impl && impl._canvas ? impl : obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add fake HTMLCanvasElement#type property:
|
// Add fake HTMLCanvasElement#type property:
|
||||||
Object.defineProperty(HTMLCanvasElement.prototype, 'type', {
|
Object.defineProperty(HTMLCanvasElement.prototype, 'type', {
|
||||||
get: function() {
|
get: function() {
|
||||||
return getImplementation(this)._type;
|
var canvas = getImplementation(this)._canvas;
|
||||||
|
return canvas && canvas.type || 'image';
|
||||||
},
|
},
|
||||||
|
|
||||||
set: function(type) {
|
set: function(type) {
|
||||||
|
@ -38,7 +42,6 @@ module.exports = function(window) {
|
||||||
size = impl._canvas || impl;
|
size = impl._canvas || impl;
|
||||||
impl._canvas = new Canvas(size.width, size.height, type);
|
impl._canvas = new Canvas(size.width, size.height, type);
|
||||||
impl._context = null;
|
impl._context = null;
|
||||||
impl._type = type;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue