Skip to content

Commit 78f5222

Browse files
committed
explicit window. for getComputedStyle
1 parent 6447bd7 commit 78f5222

File tree

7 files changed

+25
-22
lines changed

7 files changed

+25
-22
lines changed

src/plots/plots.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -213,12 +213,12 @@ plots.resize = function(gd) {
213213
return new Promise(function(resolve, reject) {
214214

215215
function isHidden(gd) {
216-
var display = getComputedStyle(gd).display;
216+
var display = window.getComputedStyle(gd).display;
217217
return !display || display === 'none';
218218
}
219219

220220
if(!gd || isHidden(gd)) {
221-
reject(new Error('Resize must be passed a plot div element.'));
221+
reject(new Error('Resize must be passed a displayed plot div element.'));
222222
}
223223

224224
if(gd._redrawTimer) clearTimeout(gd._redrawTimer);

test/jasmine/assets/custom_assertions.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,14 @@ exports.assertStyle = function(dims, color, opacity) {
4949
exports.assertHoverLabelStyle = function(g, expectation, msg, textSelector) {
5050
if(!msg) msg = '';
5151

52-
var path = g.select('path').node();
53-
expect(getComputedStyle(path).fill).toBe(expectation.bgcolor, msg + ': bgcolor');
54-
expect(getComputedStyle(path).stroke).toBe(expectation.bordercolor, msg + ': bordercolor');
55-
56-
var text = g.select(textSelector || 'text.nums').node();
57-
expect(getComputedStyle(text).fontFamily.split(',')[0]).toBe(expectation.fontFamily, msg + ': font.family');
58-
expect(parseInt(getComputedStyle(text).fontSize)).toBe(expectation.fontSize, msg + ': font.size');
59-
expect(getComputedStyle(text).fill).toBe(expectation.fontColor, msg + ': font.color');
52+
var pathStyle = window.getComputedStyle(g.select('path').node());
53+
expect(pathStyle.fill).toBe(expectation.bgcolor, msg + ': bgcolor');
54+
expect(pathStyle.stroke).toBe(expectation.bordercolor, msg + ': bordercolor');
55+
56+
var textStyle = window.getComputedStyle(g.select(textSelector || 'text.nums').node());
57+
expect(textStyle.fontFamily.split(',')[0]).toBe(expectation.fontFamily, msg + ': font.family');
58+
expect(parseInt(textStyle.fontSize)).toBe(expectation.fontSize, msg + ': font.size');
59+
expect(textStyle.fill).toBe(expectation.fontColor, msg + ': font.color');
6060
};
6161

6262
exports.assertClip = function(sel, isClipped, size, msg) {

test/jasmine/tests/geo_test.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -611,9 +611,9 @@ describe('Test geo interactions', function() {
611611
.then(function() {
612612
mouseEventScatterGeo('mousemove');
613613

614-
var path = d3.selectAll('g.hovertext').select('path').node();
615-
expect(getComputedStyle(path).fill).toEqual('rgb(255, 0, 0)', 'bgcolor');
616-
expect(getComputedStyle(path).stroke).toEqual('rgb(0, 0, 255)', 'bordecolor[0]');
614+
var pathStyle = window.getComputedStyle(d3.select('g.hovertext path').node());
615+
expect(pathStyle.fill).toEqual('rgb(255, 0, 0)', 'bgcolor');
616+
expect(pathStyle.stroke).toEqual('rgb(0, 0, 255)', 'bordecolor[0]');
617617
})
618618
.then(done);
619619
});

test/jasmine/tests/page_test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ describe('page rendering', function() {
6868
// visibility: hidden is inherited by all children (unless overridden
6969
// somewhere in the tree)
7070
allPresentationElements.each(function() {
71-
expect(getComputedStyle(this).visibility).toBe('hidden');
71+
expect(window.getComputedStyle(this).visibility).toBe('hidden');
7272
});
7373

7474
gd3.style({visibility: null, display: 'none'});

test/jasmine/tests/plot_promise_test.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -470,9 +470,11 @@ describe('Plotly.___ methods', function() {
470470
});
471471

472472
it('should return a rejected promise with no argument', function(done) {
473-
Plotly.Plots.resize().then(null, function(err) {
473+
Plotly.Plots.resize().then(function() {
474+
expect(1).toBe(0, 'We were supposed to get an error.');
475+
}, function(err) {
474476
expect(err).toBeDefined();
475-
expect(err.message).toBe('Resize must be passed a plot div element.');
477+
expect(err.message).toBe('Resize must be passed a displayed plot div element.');
476478
}).then(done);
477479
});
478480
});

test/jasmine/tests/snapshot_test.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,9 @@ describe('Plotly.Snapshot', function() {
230230
Plotly.plot(gd, subplotMock.data, subplotMock.layout).then(function() {
231231

232232
d3.select(gd).selectAll('text').each(function() {
233-
expect(getComputedStyle(this).visibility).toEqual('visible');
234-
expect(getComputedStyle(this).display).toEqual('block');
233+
var thisStyle = window.getComputedStyle(this);
234+
expect(thisStyle.visibility).toEqual('visible');
235+
expect(thisStyle.display).toEqual('block');
235236
});
236237

237238
return Plotly.Snapshot.toSVG(gd);

test/jasmine/tests/ternary_test.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,11 @@ describe('ternary plots', function() {
125125
Lib.clearThrottle();
126126
mouseEvent('mousemove', pointPos[0], pointPos[1]);
127127

128-
var path = d3.select('g.hovertext').select('path').node();
129-
var text = d3.select('g.hovertext').select('text.nums').node();
128+
var pathStyle = window.getComputedStyle(d3.select('g.hovertext path').node());
129+
var textStyle = window.getComputedStyle(d3.select('g.hovertext text.nums').node());
130130

131-
expect(getComputedStyle(path).stroke).toEqual('rgb(0, 0, 255)', 'bordercolor');
132-
expect(getComputedStyle(text).fontFamily).toEqual('Gravitas', 'font.family[0]');
131+
expect(pathStyle.stroke).toEqual('rgb(0, 0, 255)', 'bordercolor');
132+
expect(textStyle.fontFamily).toEqual('Gravitas', 'font.family[0]');
133133
})
134134
.then(done);
135135
});

0 commit comments

Comments
 (0)