mirror of
https://github.com/niklasvh/html2canvas.git
synced 2023-08-10 21:13:10 +03:00
Fix support for requirejs/amd
This commit is contained in:
parent
98ee30643a
commit
4b37909f09
@ -15,5 +15,5 @@
|
|||||||
"globals": {
|
"globals": {
|
||||||
"jQuery": true
|
"jQuery": true
|
||||||
},
|
},
|
||||||
"predef": ["-Promise"]
|
"predef": ["-Promise", "define"]
|
||||||
}
|
}
|
||||||
|
10
dist/html2canvas.js
vendored
10
dist/html2canvas.js
vendored
@ -1978,10 +1978,18 @@ html2canvas.NodeContainer = NodeContainer;
|
|||||||
html2canvas.log = log;
|
html2canvas.log = log;
|
||||||
html2canvas.utils = utils;
|
html2canvas.utils = utils;
|
||||||
|
|
||||||
module.exports = (typeof(document) === "undefined" || typeof(Object.create) !== "function" || typeof(document.createElement("canvas").getContext) !== "function") ? function() {
|
var html2canvasExport = (typeof(document) === "undefined" || typeof(Object.create) !== "function" || typeof(document.createElement("canvas").getContext) !== "function") ? function() {
|
||||||
return Promise.reject("No canvas support");
|
return Promise.reject("No canvas support");
|
||||||
} : html2canvas;
|
} : html2canvas;
|
||||||
|
|
||||||
|
module.exports = html2canvasExport;
|
||||||
|
|
||||||
|
if (typeof(define) === 'function' && define.amd) {
|
||||||
|
define('html2canvas', [], function() {
|
||||||
|
return html2canvasExport;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function renderDocument(document, options, windowWidth, windowHeight, html2canvasIndex) {
|
function renderDocument(document, options, windowWidth, windowHeight, html2canvasIndex) {
|
||||||
return createWindowClone(document, document, windowWidth, windowHeight, options, document.defaultView.pageXOffset, document.defaultView.pageYOffset).then(function(container) {
|
return createWindowClone(document, document, windowWidth, windowHeight, options, document.defaultView.pageXOffset, document.defaultView.pageYOffset).then(function(container) {
|
||||||
log("Document cloned");
|
log("Document cloned");
|
||||||
|
6
dist/html2canvas.min.js
vendored
6
dist/html2canvas.min.js
vendored
File diff suppressed because one or more lines are too long
@ -39,6 +39,7 @@
|
|||||||
"humanize-duration": "^2.0.1",
|
"humanize-duration": "^2.0.1",
|
||||||
"lodash": "^2.4.1",
|
"lodash": "^2.4.1",
|
||||||
"png-js": ">= 0.1.1",
|
"png-js": ">= 0.1.1",
|
||||||
|
"requirejs": "^2.1.20",
|
||||||
"wd": "^0.2.21"
|
"wd": "^0.2.21"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
10
src/core.js
10
src/core.js
@ -57,10 +57,18 @@ html2canvas.NodeContainer = NodeContainer;
|
|||||||
html2canvas.log = log;
|
html2canvas.log = log;
|
||||||
html2canvas.utils = utils;
|
html2canvas.utils = utils;
|
||||||
|
|
||||||
module.exports = (typeof(document) === "undefined" || typeof(Object.create) !== "function" || typeof(document.createElement("canvas").getContext) !== "function") ? function() {
|
var html2canvasExport = (typeof(document) === "undefined" || typeof(Object.create) !== "function" || typeof(document.createElement("canvas").getContext) !== "function") ? function() {
|
||||||
return Promise.reject("No canvas support");
|
return Promise.reject("No canvas support");
|
||||||
} : html2canvas;
|
} : html2canvas;
|
||||||
|
|
||||||
|
module.exports = html2canvasExport;
|
||||||
|
|
||||||
|
if (typeof(define) === 'function' && define.amd) {
|
||||||
|
define('html2canvas', [], function() {
|
||||||
|
return html2canvasExport;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function renderDocument(document, options, windowWidth, windowHeight, html2canvasIndex) {
|
function renderDocument(document, options, windowWidth, windowHeight, html2canvasIndex) {
|
||||||
return createWindowClone(document, document, windowWidth, windowHeight, options, document.defaultView.pageXOffset, document.defaultView.pageYOffset).then(function(container) {
|
return createWindowClone(document, document, windowWidth, windowHeight, options, document.defaultView.pageXOffset, document.defaultView.pageYOffset).then(function(container) {
|
||||||
log("Document cloned");
|
log("Document cloned");
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
var assert = require('assert');
|
var assert = require('assert');
|
||||||
|
var path = require('path');
|
||||||
var html2canvas = require('../../');
|
var html2canvas = require('../../');
|
||||||
|
|
||||||
describe("Package", function() {
|
describe("Package", function() {
|
||||||
@ -6,3 +7,18 @@ describe("Package", function() {
|
|||||||
assert.equal(typeof(html2canvas), "function");
|
assert.equal(typeof(html2canvas), "function");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe.only("requirejs", function() {
|
||||||
|
var requirejs = require('requirejs');
|
||||||
|
|
||||||
|
requirejs.config({
|
||||||
|
baseUrl: path.resolve(__dirname, '../../dist')
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should have html2canvas defined", function(done) {
|
||||||
|
requirejs(['html2canvas'], function(h2c) {
|
||||||
|
assert.equal(typeof(h2c), "function");
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user