mirror of
https://github.com/Hopiu/fabric.js.git
synced 2026-05-01 10:34:42 +00:00
Node canvas (#4497)
* readded * paused * test * try jsdom * restore node methods * restored * restored * fix tests
This commit is contained in:
parent
a9eacc4d74
commit
71b36f6228
3 changed files with 29 additions and 0 deletions
|
|
@ -18,6 +18,7 @@ else {
|
|||
FetchExternalResources: ['img']
|
||||
}
|
||||
});
|
||||
fabric.jsdomImplForWrapper = require('jsdom/lib/jsdom/living/generated/utils').implForWrapper;
|
||||
fabric.window = fabric.document.defaultView;
|
||||
DOMParser = require('xmldom').DOMParser;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1759,4 +1759,14 @@
|
|||
*/
|
||||
fabric.StaticCanvas.prototype.toJSON = fabric.StaticCanvas.prototype.toObject;
|
||||
|
||||
if (fabric.isLikelyNode) {
|
||||
fabric.StaticCanvas.prototype.createPNGStream = function() {
|
||||
var impl = fabric.jsdomImplForWrapper(this.lowerCanvasEl);
|
||||
return impl && impl.createPNGStream();
|
||||
};
|
||||
fabric.StaticCanvas.prototype.createJPEGStream = function(opts) {
|
||||
var impl = fabric.jsdomImplForWrapper(this.lowerCanvasEl);
|
||||
return impl && impl.createJPEGStream(opts);
|
||||
};
|
||||
}
|
||||
})();
|
||||
|
|
|
|||
|
|
@ -1572,6 +1572,24 @@
|
|||
});
|
||||
});
|
||||
|
||||
QUnit.test('createPNGStream', function(assert) {
|
||||
if (!fabric.isLikelyNode) {
|
||||
assert.ok(true, 'not supposed to run outside node');
|
||||
}
|
||||
else {
|
||||
assert.ok(typeof canvas.createPNGStream === 'function', 'there is a createPNGStream method');
|
||||
}
|
||||
});
|
||||
|
||||
QUnit.test('createJPEGStream', function(assert) {
|
||||
if (!fabric.isLikelyNode) {
|
||||
assert.ok(true, 'not supposed to run outside node');
|
||||
}
|
||||
else {
|
||||
assert.ok(typeof canvas.createJPEGStream === 'function', 'there is a createJPEGStream method');
|
||||
}
|
||||
});
|
||||
|
||||
// QUnit.test('backgroundImage', function(assert) {
|
||||
// var done = assert.async();
|
||||
// assert.deepEqual('', canvas.backgroundImage);
|
||||
|
|
|
|||
Loading…
Reference in a new issue