Skip to content

Commit 97ddf48

Browse files
committed
update jsdom to v11.2 with new API
1 parent 4f8fc66 commit 97ddf48

File tree

3 files changed

+40
-41
lines changed

3 files changed

+40
-41
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@
119119
"gzip-size": "^3.0.0",
120120
"image-size": "^0.5.1",
121121
"jasmine-core": "^2.4.1",
122-
"jsdom": "^9.5.0",
122+
"jsdom": "^11.2.0",
123123
"karma": "^1.5.0",
124124
"karma-browserify": "^5.1.1",
125125
"karma-chrome-launcher": "^2.0.0",

tasks/bundle.js

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -18,25 +18,25 @@ var DEV = (arg === 'dev') || (arg === '--dev');
1818

1919

2020
// Check if style and font build files are there
21-
var doesFileExist = common.doesFileExist;
22-
if(!doesFileExist(constants.pathToCSSBuild) || !doesFileExist(constants.pathToFontSVG)) {
23-
throw new Error([
24-
'build/ is missing one or more files',
25-
'Please run `npm run preprocess` first'
26-
].join('\n'));
27-
}
21+
// var doesFileExist = common.doesFileExist;
22+
// if(!doesFileExist(constants.pathToCSSBuild) || !doesFileExist(constants.pathToFontSVG)) {
23+
// throw new Error([
24+
// 'build/ is missing one or more files',
25+
// 'Please run `npm run preprocess` first'
26+
// ].join('\n'));
27+
// }
2828

29-
// Browserify plotly.js
30-
_bundle(constants.pathToPlotlyIndex, constants.pathToPlotlyDist, {
31-
standalone: 'Plotly',
32-
debug: DEV,
33-
pathToMinBundle: constants.pathToPlotlyDistMin
34-
});
29+
// // Browserify plotly.js
30+
// _bundle(constants.pathToPlotlyIndex, constants.pathToPlotlyDist, {
31+
// standalone: 'Plotly',
32+
// debug: DEV,
33+
// pathToMinBundle: constants.pathToPlotlyDistMin
34+
// });
3535

36-
// Browserify the geo assets
37-
_bundle(constants.pathToPlotlyGeoAssetsSrc, constants.pathToPlotlyGeoAssetsDist, {
38-
standalone: 'PlotlyGeoAssets'
39-
});
36+
// // Browserify the geo assets
37+
// _bundle(constants.pathToPlotlyGeoAssetsSrc, constants.pathToPlotlyGeoAssetsDist, {
38+
// standalone: 'PlotlyGeoAssets'
39+
// });
4040

4141
// Browserify the plotly.js with meta
4242
_bundle(constants.pathToPlotlyIndex, constants.pathToPlotlyDistWithMeta, {
@@ -45,11 +45,11 @@ _bundle(constants.pathToPlotlyIndex, constants.pathToPlotlyDistWithMeta, {
4545
then: makeSchema(constants.pathToPlotlyDistWithMeta, constants.pathToSchema)
4646
});
4747

48-
// Browserify the plotly.js partial bundles
49-
constants.partialBundlePaths.forEach(function(pathObj) {
50-
_bundle(pathObj.index, pathObj.dist, {
51-
standalone: 'Plotly',
52-
debug: DEV,
53-
pathToMinBundle: pathObj.distMin
54-
});
55-
});
48+
// // Browserify the plotly.js partial bundles
49+
// constants.partialBundlePaths.forEach(function(pathObj) {
50+
// _bundle(pathObj.index, pathObj.dist, {
51+
// standalone: 'Plotly',
52+
// debug: DEV,
53+
// pathToMinBundle: pathObj.distMin
54+
// });
55+
// });

tasks/util/make_schema.js

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,24 @@
11
var fs = require('fs');
22
var path = require('path');
3-
var jsdom = require('jsdom');
3+
var JSDOM = require('jsdom').JSDOM;
44

55
module.exports = function makeSchema(plotlyPath, schemaPath) {
66
return function() {
77
var plotlyjsCode = fs.readFileSync(plotlyPath, 'utf-8');
8-
jsdom.env({
9-
html: '<div></div>',
10-
src: [plotlyjsCode],
11-
done: function(err, window) {
12-
if(err) {
13-
console.log(err);
14-
return;
15-
}
168

17-
var plotSchema = window.Plotly.PlotSchema.get();
18-
var plotSchemaStr = JSON.stringify(plotSchema, null, 4);
19-
fs.writeFileSync(schemaPath, plotSchemaStr);
9+
var w = new JSDOM('', {runScripts: 'dangerously'}).window;
2010

21-
console.log('ok ' + path.basename(schemaPath));
22-
}
23-
});
11+
// jsdom by itself doesn't support getContext, and adding the npm canvas
12+
// package is annoying and platform-dependent.
13+
// see https://github.com/tmpvar/jsdom/issues/1782
14+
w.HTMLCanvasElement.prototype.getContext = function() { return null; };
15+
16+
w.eval(plotlyjsCode);
17+
18+
var plotSchema = w.Plotly.PlotSchema.get();
19+
var plotSchemaStr = JSON.stringify(plotSchema, null, 4);
20+
fs.writeFileSync(schemaPath, plotSchemaStr);
21+
22+
console.log('ok ' + path.basename(schemaPath));
2423
};
2524
};

0 commit comments

Comments
 (0)