Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 54bfe7a

Browse files
committed
Merge pull request plotly#195 from plotly/dep-update
Update dependencies + bye bye 'old d3 quirk'
2 parents 313fd91 + b5bf3ff commit 54bfe7a

File tree

11 files changed

+120
-51
lines changed

11 files changed

+120
-51
lines changed

package.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"citest-jasmine": "karma start test/jasmine/karma.ciconf.js",
3333
"test-image": "./tasks/test_image.sh",
3434
"test-syntax": "node test/syntax_test.js",
35-
"test": "npm run test-jasmine && npm test-image",
35+
"test": "npm run test-jasmine && npm test-image && npm test-syntax",
3636
"start-test_dashboard": "node devtools/test_dashboard/server.js",
3737
"start-image_viewer": "node devtools/image_viewer/server.js",
3838
"baseline": "./tasks/baseline.sh",
@@ -44,7 +44,7 @@
4444
"alpha-shape": "^1.0.0",
4545
"arraytools": "^1.0.0",
4646
"convex-hull": "^1.0.3",
47-
"d3": "3.5.6",
47+
"d3": "^3.5.12",
4848
"delaunay-triangulate": "^1.1.6",
4949
"es6-promise": "^3.0.2",
5050
"fast-isnumeric": "^1.1.1",
@@ -73,17 +73,17 @@
7373
"robust-orientation": "^1.1.3",
7474
"sane-topojson": "^1.2.0",
7575
"superscript-text": "^1.0.0",
76-
"tinycolor2": "1.1.2",
77-
"topojson": "^1.6.19"
76+
"tinycolor2": "^1.3.0",
77+
"topojson": "^1.6.20"
7878
},
7979
"devDependencies": {
80-
"brfs": "^1.4.1",
81-
"browserify": "^12.0.1",
82-
"browserify-transform-tools": "^1.5.0",
80+
"brfs": "^1.4.3",
81+
"browserify": "^13.0.0",
82+
"browserify-transform-tools": "^1.5.1",
8383
"ecstatic": "^1.2.0",
8484
"eslint": "^1.10.3",
8585
"falafel": "^1.2.0",
86-
"glob": "^6.0.1",
86+
"glob": "^6.0.4",
8787
"jasmine-core": "^2.3.4",
8888
"karma": "^0.13.15",
8989
"karma-browserify": "^4.4.1",
@@ -97,7 +97,7 @@
9797
"prettysize": "0.0.3",
9898
"through2": "^2.0.0",
9999
"uglify-js": "^2.5.0",
100-
"watchify": "^3.6.0",
101-
"xml2js": "^0.4.15"
100+
"watchify": "^3.7.0",
101+
"xml2js": "^0.4.16"
102102
}
103103
}

src/components/drawing/index.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ var Plotly = require('../../plotly');
1313
var d3 = require('d3');
1414
var isNumeric = require('fast-isnumeric');
1515

16+
var xmlnsNamespaces = require('../../constants/xmlns_namespaces');
1617
var subTypes = require('../../traces/scatter/subtypes');
1718
var makeBubbleSizeFn = require('../../traces/scatter/make_bubble_size_func');
1819

@@ -449,12 +450,8 @@ drawing.makeTester = function(gd) {
449450
.data([0]);
450451

451452
tester.enter().append('svg')
452-
.attr({
453-
id: 'js-plotly-tester',
454-
xmlns: 'http://www.w3.org/2000/svg',
455-
// odd d3 quirk - need namespace twice??
456-
'xmlns:xmlns:xlink': 'http://www.w3.org/1999/xlink'
457-
})
453+
.attr('id', 'js-plotly-tester')
454+
.attr(xmlnsNamespaces.svgAttrs)
458455
.style({
459456
position: 'absolute',
460457
left: '-10000px',

src/constants/xmlns_namespaces.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/**
2+
* Copyright 2012-2016, Plotly, Inc.
3+
* All rights reserved.
4+
*
5+
* This source code is licensed under the MIT license found in the
6+
* LICENSE file in the root directory of this source tree.
7+
*/
8+
9+
10+
'use strict';
11+
12+
13+
exports.xmlns = 'http://www.w3.org/2000/xmlns/';
14+
exports.svg = 'http://www.w3.org/2000/svg';
15+
exports.xlink = 'http://www.w3.org/1999/xlink';
16+
17+
// the 'old' d3 quirk got fix in v3.5.7
18+
// https://github.com/mbostock/d3/commit/a6f66e9dd37f764403fc7c1f26be09ab4af24fed
19+
exports.svgAttrs = {
20+
xmlns: exports.svg,
21+
'xmlns:xlink': exports.xlink
22+
};

src/lib/svg_text_utils.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,23 @@
1414
var Plotly = require('../plotly');
1515
var d3 = require('d3');
1616

17+
var xmlnsNamespaces = require('../constants/xmlns_namespaces');
18+
1719
var util = module.exports = {};
1820

1921
// Append SVG
2022

2123
d3.selection.prototype.appendSVG = function(_svgString) {
22-
var skeleton = '<svg xmlns="http://www.w3.org/2000/svg" ' +
23-
'xmlns:xlink="http://www.w3.org/1999/xlink">' +
24-
_svgString + '</svg>',
25-
dom = new DOMParser().parseFromString(skeleton, 'application/xml'),
24+
var skeleton = [
25+
'<svg xmlns="', xmlnsNamespaces.svg, '" ',
26+
'xmlns:xlink="', xmlnsNamespaces.xlink, '">',
27+
_svgString,
28+
'</svg>'
29+
].join('');
30+
31+
var dom = new DOMParser().parseFromString(skeleton, 'application/xml'),
2632
childNode = dom.documentElement.firstChild;
33+
2734
while(childNode) {
2835
this.node().appendChild(this.node().ownerDocument.importNode(childNode, true));
2936
childNode = childNode.nextSibling;

src/plot_api/plot_api.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ var Legend = require('../components/legend');
2828
var Shapes = require('../components/shapes');
2929
var Titles = require('../components/titles');
3030
var manageModeBar = require('../components/modebar/manage');
31+
var xmlnsNamespaces = require('../constants/xmlns_namespaces');
3132

3233

3334
/**
@@ -2567,11 +2568,7 @@ function makePlotFramework(gd) {
25672568
}
25682569

25692570
fullLayout._paperdiv.selectAll('.main-svg')
2570-
.attr({
2571-
xmlns: 'http://www.w3.org/2000/svg',
2572-
// odd d3 quirk - need namespace twice??
2573-
'xmlns:xmlns:xlink': 'http://www.w3.org/1999/xlink'
2574-
});
2571+
.attr(xmlnsNamespaces.svgAttrs);
25752572

25762573
fullLayout._defs = fullLayout._paper.append('defs')
25772574
.attr('id', 'defs-' + fullLayout._uid);

src/plots/geo/geo.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ var createGeoScale = require('./set_scale');
2424
var createGeoZoom = require('./zoom');
2525
var createGeoZoomReset = require('./zoom_reset');
2626

27+
var xmlnsNamespaces = require('../../constants/xmlns_namespaces');
2728
var constants = require('../../constants/geo_constants');
2829
var topojsonUtils = require('../../lib/topojson_utils');
2930
var topojsonFeature = require('topojson').feature;
@@ -217,10 +218,7 @@ proto.makeFramework = function() {
217218

218219
var hoverContainer = this.hoverContainer = geoDiv.append('svg');
219220
hoverContainer
220-
.attr({
221-
xmlns:'http://www.w3.org/2000/svg',
222-
'xmlns:xmlns:xlink': 'http://www.w3.org/1999/xlink'
223-
})
221+
.attr(xmlnsNamespaces.svgAttrs)
224222
.style({
225223
'position': 'absolute',
226224
'z-index': 20,
@@ -229,9 +227,8 @@ proto.makeFramework = function() {
229227

230228
var framework = this.framework = geoDiv.append('svg');
231229
framework
230+
.attr(xmlnsNamespaces.svgAttrs)
232231
.attr({
233-
'xmlns':'http://www.w3.org/2000/svg',
234-
'xmlns:xmlns:xlink': 'http://www.w3.org/1999/xlink',
235232
'position': 'absolute',
236233
'preserveAspectRatio': 'none'
237234
});

src/plots/polar/micropolar.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1071,7 +1071,7 @@ var extendDeepAll = Plotly.Lib.extendDeepAll;
10711071
width: 300,
10721072
height: height + lineHeight,
10731073
xmlns: 'http://www.w3.org/2000/svg',
1074-
'xmlns:xmlns:xlink': 'http://www.w3.org/1999/xlink',
1074+
'xmlns:xlink': 'http://www.w3.org/1999/xlink',
10751075
version: '1.1'
10761076
});
10771077
svgEnter.append('g').classed('legend-axis', true);

src/snapshot/tosvg.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@
99

1010
'use strict';
1111

12-
var Plotly = require('../plotly'),
13-
d3 = require('d3');
12+
var Plotly = require('../plotly');
13+
var d3 = require('d3');
14+
15+
var xmlnsNamespaces = require('../constants/xmlns_namespaces');
16+
1417

1518
module.exports = function toSVG(gd, format) {
1619

@@ -139,8 +142,8 @@ module.exports = function toSVG(gd, format) {
139142

140143
// fix for IE namespacing quirk?
141144
// http://stackoverflow.com/questions/19610089/unwanted-namespaces-on-svg-markup-when-using-xmlserializer-in-javascript-with-ie
142-
svg.node().setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns', 'http://www.w3.org/2000/svg');
143-
svg.node().setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:xlink', 'http://www.w3.org/1999/xlink');
145+
svg.node().setAttributeNS(xmlnsNamespaces.xmlns, 'xmlns', xmlnsNamespaces.svg);
146+
svg.node().setAttributeNS(xmlnsNamespaces.xmlns, 'xmlns:xlink', xmlnsNamespaces.xlink);
144147

145148
var s = new window.XMLSerializer().serializeToString(svg.node());
146149
s = Plotly.util.html_entity_decode(s);
@@ -154,8 +157,8 @@ function insertGlImage(fullLayout, scene, opts) {
154157

155158
fullLayout._glimages.append('svg:image')
156159
.attr({
157-
xmlns:'http://www.w3.org/2000/svg',
158-
'xlink:xlink:href': imageData, // odd d3 quirk, need namespace twice
160+
xmlns: xmlnsNamespaces.svg,
161+
'xlink:href': imageData,
159162
x: opts.x,
160163
y: opts.y,
161164
width: opts.width,

src/traces/heatmap/plot.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ var tinycolor = require('tinycolor2');
1515
var Plotly = require('../../plotly');
1616
var Lib = require('../../lib');
1717
var getColorscale = require('../../components/colorscale/get_scale');
18+
var xmlnsNamespaces = require('../../constants/xmlns_namespaces');
1819

1920
var maxRowLength = require('./max_row_length');
2021

@@ -372,8 +373,8 @@ function plotOne(gd, plotinfo, cd) {
372373
.classed(id, true)
373374
.datum(cd[0])
374375
.attr({
375-
xmlns: 'http://www.w3.org/2000/svg',
376-
'xlink:xlink:href': canvas.toDataURL('image/png'), // odd d3 quirk, need namespace twice
376+
xmlns: xmlnsNamespaces.svg,
377+
'xlink:href': canvas.toDataURL('image/png'),
377378
height: imageHeight,
378379
width: imageWidth,
379380
x: left,

test/jasmine/tests/plot_interact_test.js

Lines changed: 52 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@ var destroyGraphDiv = require('../assets/destroy_graph_div');
99
describe('Test plot structure', function() {
1010
'use strict';
1111

12+
function assertNamespaces(node) {
13+
expect(node.getAttribute('xmlns'))
14+
.toEqual('http://www.w3.org/2000/svg');
15+
expect(node.getAttribute('xmlns:xlink'))
16+
.toEqual('http://www.w3.org/1999/xlink');
17+
}
18+
1219
afterEach(destroyGraphDiv);
1320

1421
describe('cartesian plots', function() {
@@ -21,17 +28,17 @@ describe('Test plot structure', function() {
2128

2229
it('has one *subplot xy* node', function() {
2330
var nodes = d3.selectAll('g.subplot.xy');
24-
expect(nodes[0].length).toEqual(1);
31+
expect(nodes.size()).toEqual(1);
2532
});
2633

2734
it('has one *scatterlayer* node', function() {
2835
var nodes = d3.selectAll('g.scatterlayer');
29-
expect(nodes[0].length).toEqual(1);
36+
expect(nodes.size()).toEqual(1);
3037
});
3138

3239
it('has as many *trace scatter* nodes as there are traces', function() {
3340
var nodes = d3.selectAll('g.trace.scatter');
34-
expect(nodes[0].length).toEqual(mock.data.length);
41+
expect(nodes.size()).toEqual(mock.data.length);
3542
});
3643

3744
it('has as many *point* nodes as there are traces', function() {
@@ -42,7 +49,16 @@ describe('Test plot structure', function() {
4249
Npts += trace.x.length;
4350
});
4451

45-
expect(nodes[0].length).toEqual(Npts);
52+
expect(nodes.size()).toEqual(Npts);
53+
});
54+
55+
it('has the correct name spaces', function() {
56+
var mainSVGs = d3.selectAll('.main-svg');
57+
58+
mainSVGs.each(function() {
59+
var node = this;
60+
assertNamespaces(node);
61+
});
4662
});
4763
});
4864

@@ -61,7 +77,19 @@ describe('Test plot structure', function() {
6177
Npts += trace.values.length;
6278
});
6379

64-
expect(nodes[0].length).toEqual(Npts);
80+
expect(nodes.size()).toEqual(Npts);
81+
});
82+
83+
it('has the correct name spaces', function() {
84+
var mainSVGs = d3.selectAll('.main-svg');
85+
86+
mainSVGs.each(function() {
87+
var node = this;
88+
assertNamespaces(node);
89+
});
90+
91+
var testerSVG = d3.selectAll('#js-plotly-tester');
92+
assertNamespaces(testerSVG.node());
6593
});
6694
});
6795
});
@@ -82,7 +110,7 @@ describe('Test plot structure', function() {
82110
if(items) Npts += items.length;
83111
});
84112

85-
expect(nodes[0].length).toEqual(Npts);
113+
expect(nodes.size()).toEqual(Npts);
86114
});
87115

88116
it('has as many *point* nodes as there are marker points', function() {
@@ -94,7 +122,23 @@ describe('Test plot structure', function() {
94122
if(items) Npts += items.length;
95123
});
96124

97-
expect(nodes[0].length).toEqual(Npts);
125+
expect(nodes.size()).toEqual(Npts);
126+
});
127+
128+
it('has the correct name spaces', function() {
129+
var mainSVGs = d3.selectAll('.main-svg');
130+
131+
mainSVGs.each(function() {
132+
var node = this;
133+
assertNamespaces(node);
134+
});
135+
136+
var geoSVGs = d3.select('#geo').selectAll('svg');
137+
138+
geoSVGs.each(function() {
139+
var node = this;
140+
assertNamespaces(node);
141+
});
98142
});
99143
});
100144

@@ -113,7 +157,7 @@ describe('Test plot structure', function() {
113157
Npts += trace.r.length;
114158
});
115159

116-
expect(nodes[0].length).toEqual(Npts);
160+
expect(nodes.size()).toEqual(Npts);
117161
});
118162
});
119163
});

test/syntax_test.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ var glob = require('glob');
66

77
var constants = require('../tasks/util/constants');
88

9-
var focusGlobals = ['fdescribe', 'fit'];
9+
var focusGlobals = ['fdescribe', 'fit', 'xdescribe', 'xit'];
1010
var logs = [];
1111

1212

@@ -19,12 +19,13 @@ glob(path.join(constants.pathToJasmineTests, '**/*.js'), function(err, files) {
1919
logs.push([
2020
path.basename(file),
2121
'[line ' + node.loc.start.line + '] :',
22-
'contains either a *fdescribe* or a *fit* block.'
22+
'contains either a *fdescribe*, *fit*,',
23+
'*xdescribe* or *xit* block.'
2324
].join(' '));
2425
}
2526
});
2627

2728
});
2829

29-
if(logs.length) throw new Error(logs.join('\n'));
30+
if(logs.length) throw new Error('\n' + logs.join('\n') + '\n');
3031
});

0 commit comments

Comments
 (0)