Skip to content

Use correct parent document when necessary: fixes 702 #2 #758

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 115 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
115 commits
Select commit Hold shift + click to select a range
5d7904e
Ensure the dragcover is rendered on the proper element.
nielsenb-jf Jul 12, 2016
d69b72d
Be consistent with use of ownerDocument.
nielsenb-jf Jul 12, 2016
02ac18f
Merge branch 'master' into coverslip_fix
nielsenb-jf Jul 12, 2016
f10706d
Ensure range sliders use the correct child document / window.
nielsenb-jf Jul 13, 2016
0bec933
Properly resize plot based on plot parent window.
nielsenb-jf Jul 13, 2016
bac79fe
Merge branch 'master' into child_window_fixes
nielsenb-jf Jul 14, 2016
f96101c
Only inject Plotly CSS into the document a plot is being rendered in.
nielsenb-jf Jul 14, 2016
5f57f08
Don't hardcode CSS in plotcss_injector, instead use the generated style
nielsenb-jf Jul 14, 2016
a1204ec
Merge branch 'master' into child_window_fixes
nielsenb-jf Jul 15, 2016
e19f8d8
Fix formatting.
nielsenb-jf Jul 15, 2016
5109efc
bump karma to 1.1.0
etpinard Jul 4, 2016
4defbab
bump eslint to 3.0.0
etpinard Jul 4, 2016
4a04474
bar: set marker.line.width dflt to 0
etpinard Jun 30, 2016
eec4a20
test: add bargap 0 mock
etpinard Jun 30, 2016
d0ad30f
test-runner: check if baseline img exist before px comparison
etpinard Jun 30, 2016
855a339
Ensure the dragcover is rendered on the proper element.
nielsenb-jf Jul 12, 2016
aa1c3c4
Be consistent with use of ownerDocument.
nielsenb-jf Jul 12, 2016
10c751b
bar: skip over bars with non-numeric size in setPositions
etpinard Jul 5, 2016
89c7c79
test: add stack with gaps mock
etpinard Jul 5, 2016
198390c
test-assets: add msg-extra argument to is-close array matchers
etpinard Jul 5, 2016
275b110
test-assets: don't try to compute dist between non-numeric elements
etpinard Jul 5, 2016
36216f9
lint: flatten bar test suite
etpinard Jul 5, 2016
8bea10a
test: add bar calc / setPositions tests
etpinard Jul 5, 2016
a2ec12d
fix issue with bar releative mode when first bucket is 0 or string
keeganmccallum Jun 23, 2016
ae45238
lint: bar setPositions comments + spaces
etpinard Jul 5, 2016
6d0539a
test: add bar setPositions test cases for relative of pos 0 / -0
etpinard Jul 5, 2016
36ff540
Memory leak fix candidates: 1) purge must destroy scene2d otherwise r…
monfera Jul 6, 2016
4c1fc94
Lint
monfera Jul 6, 2016
57ce709
Call cleanPlot from newPlot directly; Changed the location of the tra…
monfera Jul 8, 2016
56f026d
Adding test cases that check that Plotly.newPlot indeed causes derefe…
monfera Jul 8, 2016
db708cf
lint: sub this -> self
etpinard Jul 7, 2016
e8ea6f6
mapbox: emit plotly_relayout event mouse move
etpinard Jul 7, 2016
295ec46
lint: flattern Fx test suite
etpinard Jul 8, 2016
e648ce2
update 'dragmode' cursor in relayout NOT modebar
etpinard Jul 8, 2016
62782f9
dry: check for if dragbox is main-drag only once
etpinard Jul 8, 2016
b591329
fixup flatten
etpinard Jul 8, 2016
e1d5200
fx: make mainDrag active if 'lasso' / 'select' even w/ fixed ranges
etpinard Jul 8, 2016
69678ce
test: check main drag update on relayout
etpinard Jul 8, 2016
33937d7
Reifies not yet covered, preexisting behavior of Lib.extendDeep to ch…
monfera Jul 11, 2016
cf3ffea
update changelog for v1.14.2
etpinard Jul 11, 2016
7459908
1.14.2
etpinard Jul 11, 2016
87f2bb1
Speed up Lib.extendDeep (_extend) for primitive arrays
monfera Jul 11, 2016
f68e9e8
fix gl2d snapshot rendering
mikolalysenko May 26, 2016
6a30101
lint
etpinard Jul 11, 2016
1ec2f38
Bypassing most of the heavy lifting in the rAF for when there's no us…
monfera Jul 9, 2016
162606e
Use trace.uid rather than hanging on to the entire trace just for the…
monfera Jul 11, 2016
cc1ab12
test: make convertToTspans suite more robust
etpinard Jul 11, 2016
2f344a0
lib: handle '=' and '&' in anchor href
etpinard Jul 11, 2016
345ddd5
test: add tests for XSS attack in text href
etpinard Jul 11, 2016
170acfb
Queue length limitation concept
monfera Jul 7, 2016
f77035d
Lint away queue length logging
monfera Jul 7, 2016
280d745
lint: no need to check for Plotly.Queue existence
etpinard Jul 11, 2016
107ef4f
lib: use queue length set via setPlotConfig
etpinard Jul 11, 2016
47e11da
test: add test for queue
etpinard Jul 11, 2016
3988724
lib: make sure queueObj exist before trying to unshift it
etpinard Jul 12, 2016
bbedf78
Ensure range sliders use the correct child document / window.
nielsenb-jf Jul 13, 2016
00b8ea3
Properly resize plot based on plot parent window.
nielsenb-jf Jul 13, 2016
38666f8
add Lib.validate function:
etpinard Jun 23, 2016
6ebcad3
make is-valid colorscale array more strict
etpinard Jun 27, 2016
b650be3
make string val type more strict:
etpinard Jun 27, 2016
6842df3
add a few test cases for coerce + 'info_array'
etpinard Jun 27, 2016
84846e2
add validateFunction for info_array
etpinard Jun 27, 2016
ca0532f
make 'dflt' a required opts for 'subplotid' val types
etpinard Jun 27, 2016
6edfb7c
add validate function for 'subplotid' val types
etpinard Jun 27, 2016
e6ee376
add Plotly.validate:
etpinard Jun 27, 2016
5e3c26e
validate: add support for is isSubplotObj attributes
etpinard Jul 6, 2016
531cc06
validate: add 'container' error code
etpinard Jul 6, 2016
3fb41b5
on 2nd thought, only coerce numbers to strings
etpinard Jul 12, 2016
746bcff
clean up is-valid-colorscale logic
etpinard Jul 12, 2016
62981d7
make info_array validate func more strict:
etpinard Jul 12, 2016
abfae28
validate: flatten Plotly.validate output
etpinard Jul 13, 2016
8818e41
Only inject Plotly CSS into the document a plot is being rendered in.
nielsenb-jf Jul 14, 2016
7680b8f
Don't hardcode CSS in plotcss_injector, instead use the generated style
nielsenb-jf Jul 14, 2016
a04e7ff
When injecting styles, don't inject a duplicate selector.
nielsenb-jf Jul 14, 2016
5b02a84
Don't keep a reference to the stylesheet in lib.
nielsenb-jf Jul 14, 2016
e930a63
Add a z-index to js-plotly-tester as a workaround for a chrome bug (#…
Jul 14, 2016
02b230e
Make injectStyles take the graph div (gd) as the argument.
nielsenb-jf Jul 15, 2016
f75d581
Move addStyleRule code to injectStyles, delete lib.addStyleRule.
nielsenb-jf Jul 15, 2016
cbf63ba
Only injectStyles if they haven't already been injected.
nielsenb-jf Jul 15, 2016
1bb2cbe
Graph div now keeps a _document reference to the document it's render…
nielsenb-jf Jul 15, 2016
3d3388b
scattermapbox: override hash item if undefined (in case === 0)
etpinard Jul 15, 2016
1e1868b
Make sure graph div _document property is set for drag element tests.
nielsenb-jf Jul 18, 2016
242d767
Add some tests to make sure CSS injection is happening correctly.
nielsenb-jf Jul 18, 2016
8814117
Move some common code to a helpers file so they can be used in tests.
nielsenb-jf Jul 18, 2016
a5fb869
Use CSS helper functions.
nielsenb-jf Jul 18, 2016
36ee825
Move CSS injection tests to plt_css_test.js.
nielsenb-jf Jul 19, 2016
d3e1427
Use @src and @build macros.
nielsenb-jf Jul 19, 2016
20724de
Cleanup _document and _plotCSSLoaded in plots.purge.
nielsenb-jf Jul 19, 2016
0da000e
Notifier now requires a graph div as the first argument.
nielsenb-jf Jul 19, 2016
d3fc39d
Add issue and pr template from CONTRIBUTING.md
rreusser Jul 19, 2016
21a250a
Fix naming of PR template
rreusser Jul 19, 2016
9c8b402
Actually include the PR template
rreusser Jul 19, 2016
febed0e
Guideline cleanup
rreusser Jul 19, 2016
b9d936a
Punctuation detail
rreusser Jul 19, 2016
d526dd3
When injecting styles, don't inject a duplicate selector.
nielsenb-jf Jul 14, 2016
b8c5e10
Don't keep a reference to the stylesheet in lib.
nielsenb-jf Jul 14, 2016
457a49c
Merge branch 'child_window_fixes' into child_css
nielsenb-jf Jul 15, 2016
96e6815
Fix formatting.
nielsenb-jf Jul 15, 2016
43d42f8
Merge branch 'child_window_fixes' into child_css
nielsenb-jf Jul 15, 2016
f97305f
Make injectStyles take the graph div (gd) as the argument.
nielsenb-jf Jul 15, 2016
ae9b2ba
Move addStyleRule code to injectStyles, delete lib.addStyleRule.
nielsenb-jf Jul 15, 2016
eb536d4
Only injectStyles if they haven't already been injected.
nielsenb-jf Jul 15, 2016
f03b7b3
Graph div now keeps a _document reference to the document it's render…
nielsenb-jf Jul 15, 2016
bc07d60
Merge branch 'master' into child_window_fixes
nielsenb-jf Jul 18, 2016
2f25141
Make sure graph div _document property is set for drag element tests.
nielsenb-jf Jul 18, 2016
99bb492
Add some tests to make sure CSS injection is happening correctly.
nielsenb-jf Jul 18, 2016
b0e9c0c
Move some common code to a helpers file so they can be used in tests.
nielsenb-jf Jul 18, 2016
1efd493
Use CSS helper functions.
nielsenb-jf Jul 18, 2016
000104e
Move CSS injection tests to plt_css_test.js.
nielsenb-jf Jul 19, 2016
413b731
Use @src and @build macros.
nielsenb-jf Jul 19, 2016
d668340
Notifier now requires a graph div as the first argument.
nielsenb-jf Jul 19, 2016
2e8a1ec
Cleanup _document and _plotCSSLoaded in plots.purge.
nielsenb-jf Jul 19, 2016
f8794bc
Merge branch 'notifier_fixes' into child_window_fixes
nielsenb-jf Jul 19, 2016
5c0fa8d
Merge branch 'master' into child_window_fixes
nielsenb-jf Jul 20, 2016
114c13d
Merge branch 'child_window_fixes' of github.com:nielsenb-jf/plotly.js…
nielsenb-jf Jul 20, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions build/plotcss.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
'use strict';

var Plotly = require('../src/plotly');
var rules = {
"X,X div": "font-family:'Open Sans', verdana, arial, sans-serif;margin:0;padding:0;",
"X input,X button": "font-family:'Open Sans', verdana, arial, sans-serif;",
Expand Down Expand Up @@ -54,9 +53,4 @@ var rules = {
"Y .notifier-close:hover": "color:#444;text-decoration:none;cursor:pointer;"
};

for(var selector in rules) {
var fullSelector = selector.replace(/^,/,' ,')
.replace(/X/g, '.js-plotly-plot .plotly')
.replace(/Y/g, '.plotly-notifier');
Plotly.Lib.addStyleRule(fullSelector, rules[selector]);
}
module.exports = rules;
10 changes: 5 additions & 5 deletions src/components/dragelement/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ dragElement.init = function init(options) {

if(options.prepFn) options.prepFn(e, startX, startY);

dragCover = coverSlip();
dragCover = coverSlip(gd);

dragCover.onmousemove = onMove;
dragCover.onmouseup = onDone;
Expand Down Expand Up @@ -139,7 +139,7 @@ dragElement.init = function init(options) {
if(options.doneFn) options.doneFn(gd._dragged, numClicks);

if(!gd._dragged) {
var e2 = document.createEvent('MouseEvents');
var e2 = gd._document.createEvent('MouseEvents');
e2.initEvent('click', true, true);
initialTarget.dispatchEvent(e2);
}
Expand All @@ -159,8 +159,8 @@ dragElement.init = function init(options) {
options.element.style.pointerEvents = 'all';
};

function coverSlip() {
var cover = document.createElement('div');
function coverSlip(gd) {
var cover = gd._document.createElement('div');

cover.className = 'dragcover';
var cStyle = cover.style;
Expand All @@ -172,7 +172,7 @@ function coverSlip() {
cStyle.zIndex = 999999999;
cStyle.background = 'none';

document.body.appendChild(cover);
gd._document.body.appendChild(cover);

return cover;
}
Expand Down
8 changes: 4 additions & 4 deletions src/components/modebar/buttons.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,19 @@ modeBarButtons.toImage = {
click: function(gd) {
var format = 'png';

Lib.notifier('Taking snapshot - this may take a few seconds', 'long');
Lib.notifier(gd, 'Taking snapshot - this may take a few seconds', 'long');

if(Lib.isIE()) {
Lib.notifier('IE only supports svg. Changing format to svg.', 'long');
Lib.notifier(gd, 'IE only supports svg. Changing format to svg.', 'long');
format = 'svg';
}

downloadImage(gd, {'format': format})
.then(function(filename) {
Lib.notifier('Snapshot succeeded - ' + filename, 'long');
Lib.notifier(gd, 'Snapshot succeeded - ' + filename, 'long');
})
.catch(function() {
Lib.notifier('Sorry there was a problem downloading your snapshot!', 'long');
Lib.notifier(gd, 'Sorry there was a problem downloading your snapshot!', 'long');
});
}
};
Expand Down
34 changes: 17 additions & 17 deletions src/components/rangeslider/create_slider.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ module.exports = function createSlider(gd) {
var minStart = 0,
maxStart = width;

var slider = document.createElementNS(svgNS, 'g');
var slider = gd._document.createElementNS(svgNS, 'g');
helpers.setAttributes(slider, {
'class': 'range-slider',
'data-min': minStart,
Expand All @@ -43,7 +43,7 @@ module.exports = function createSlider(gd) {
});


var sliderBg = document.createElementNS(svgNS, 'rect'),
var sliderBg = gd._document.createElementNS(svgNS, 'rect'),
borderCorrect = options.borderwidth % 2 === 0 ? options.borderwidth : options.borderwidth - 1;
helpers.setAttributes(sliderBg, {
'fill': options.bgcolor,
Expand All @@ -56,7 +56,7 @@ module.exports = function createSlider(gd) {
});


var maskMin = document.createElementNS(svgNS, 'rect');
var maskMin = gd._document.createElementNS(svgNS, 'rect');
helpers.setAttributes(maskMin, {
'x': 0,
'width': minStart,
Expand All @@ -65,7 +65,7 @@ module.exports = function createSlider(gd) {
});


var maskMax = document.createElementNS(svgNS, 'rect');
var maskMax = gd._document.createElementNS(svgNS, 'rect');
helpers.setAttributes(maskMax, {
'x': maxStart,
'width': width - maxStart,
Expand All @@ -74,9 +74,9 @@ module.exports = function createSlider(gd) {
});


var grabberMin = document.createElementNS(svgNS, 'g'),
grabAreaMin = document.createElementNS(svgNS, 'rect'),
handleMin = document.createElementNS(svgNS, 'rect');
var grabberMin = gd._document.createElementNS(svgNS, 'g'),
grabAreaMin = gd._document.createElementNS(svgNS, 'rect'),
handleMin = gd._document.createElementNS(svgNS, 'rect');
helpers.setAttributes(grabberMin, { 'transform': 'translate(' + (minStart - handleWidth - 1) + ')' });
helpers.setAttributes(grabAreaMin, {
'width': 10,
Expand All @@ -97,9 +97,9 @@ module.exports = function createSlider(gd) {
helpers.appendChildren(grabberMin, [handleMin, grabAreaMin]);


var grabberMax = document.createElementNS(svgNS, 'g'),
grabAreaMax = document.createElementNS(svgNS, 'rect'),
handleMax = document.createElementNS(svgNS, 'rect');
var grabberMax = gd._document.createElementNS(svgNS, 'g'),
grabAreaMax = gd._document.createElementNS(svgNS, 'rect'),
handleMax = gd._document.createElementNS(svgNS, 'rect');
helpers.setAttributes(grabberMax, { 'transform': 'translate(' + maxStart + ')' });
helpers.setAttributes(grabAreaMax, {
'width': 10,
Expand All @@ -120,7 +120,7 @@ module.exports = function createSlider(gd) {
helpers.appendChildren(grabberMax, [handleMax, grabAreaMax]);


var slideBox = document.createElementNS(svgNS, 'rect');
var slideBox = gd._document.createElementNS(svgNS, 'rect');
helpers.setAttributes(slideBox, {
'x': minStart,
'width': maxStart - minStart,
Expand All @@ -137,8 +137,8 @@ module.exports = function createSlider(gd) {
minVal = slider.getAttribute('data-min'),
maxVal = slider.getAttribute('data-max');

window.addEventListener('mousemove', mouseMove);
window.addEventListener('mouseup', mouseUp);
gd._document.defaultView.addEventListener('mousemove', mouseMove);
gd._document.defaultView.addEventListener('mouseup', mouseUp);

function mouseMove(e) {
var delta = +e.clientX - startX,
Expand Down Expand Up @@ -189,8 +189,8 @@ module.exports = function createSlider(gd) {
}

function mouseUp() {
window.removeEventListener('mousemove', mouseMove);
window.removeEventListener('mouseup', mouseUp);
gd._document.defaultView.removeEventListener('mousemove', mouseMove);
gd._document.defaultView.removeEventListener('mouseup', mouseUp);
slider.style.cursor = 'auto';
}
});
Expand Down Expand Up @@ -222,8 +222,8 @@ module.exports = function createSlider(gd) {

function setDataRange(dataMin, dataMax) {

if(window.requestAnimationFrame) {
window.requestAnimationFrame(function() {
if(gd._document.defaultView.requestAnimationFrame) {
gd._document.defaultView.requestAnimationFrame(function() {
Plotly.relayout(gd, 'xaxis.range', [dataMin, dataMax]);
});
} else {
Expand Down
38 changes: 38 additions & 0 deletions src/css/helpers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/**
* Copyright 2012-2016, Plotly, Inc.
* All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/


'use strict';

// expands a plotcss selector
exports.buildFullSelector = function buildFullSelector(selector) {
var fullSelector = selector.replace(/,/, ', ')
.replace(/:after/g, '::after')
.replace(/:before/g, '::before')
.replace(/X/g, '.js-plotly-plot .plotly')
.replace(/Y/g, '.plotly-notifier');

return fullSelector;
};

// Gets all the rules currently attached to the document
exports.getAllRuleSelectors = function getAllRuleSelectors(sourceDocument) {
var allSelectors = [];

for(var i = 0; i < sourceDocument.styleSheets.length; i++) {
var styleSheet = sourceDocument.styleSheets[i];

for(var j = 0; j < styleSheet.cssRules.length; j++) {
var cssRule = styleSheet.cssRules[j];

allSelectors.push(cssRule.selectorText);
}
}

return allSelectors;
};
52 changes: 52 additions & 0 deletions src/css/plotcss_injector.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/**
* Copyright 2012-2016, Plotly, Inc.
* All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/


'use strict';

var helpers = require('./helpers');
var lib = require('../lib');
var plotcss = require('../../build/plotcss');

// Inject styling information into the document containing the graph div
module.exports = function injectStyles(gd) {
// If the graph div has already been styled, bail
if(gd._plotCSSLoaded) return;

var targetSelectors = helpers.getAllRuleSelectors(gd._document);
var targetStyleSheet = null;

if(gd._document.getElementsByTagName('style').length === 0) {
var style = gd._document.createElement('style');
// WebKit hack :(
style.appendChild(gd._document.createTextNode(''));
gd._document.head.appendChild(style);
targetStyleSheet = style.sheet;
}
else {
// Just grab the first style element to append to
targetStyleSheet = gd._document.getElementsByTagName('style')[0].sheet;
}

for(var selector in plotcss) {
var fullSelector = helpers.buildFullSelector(selector);

// Don't duplicate selectors
if(targetSelectors.indexOf(fullSelector) === -1) {
if(targetStyleSheet.insertRule) {
targetStyleSheet.insertRule(fullSelector + '{' + plotcss[selector] + '}', 0);
}
else if(targetStyleSheet.addRule) {
targetStyleSheet.addRule(fullSelector, plotcss[selector], 0);
}
else lib.warn('injectStyles failed');
}
}

gd._plotCSSLoaded = true;
};
24 changes: 0 additions & 24 deletions src/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -388,30 +388,6 @@ lib.removeElement = function(el) {
if(elParent) elParent.removeChild(el);
};

/**
* for dynamically adding style rules
* makes one stylesheet that contains all rules added
* by all calls to this function
*/
lib.addStyleRule = function(selector, styleString) {
if(!lib.styleSheet) {
var style = document.createElement('style');
// WebKit hack :(
style.appendChild(document.createTextNode(''));
document.head.appendChild(style);
lib.styleSheet = style.sheet;
}
var styleSheet = lib.styleSheet;

if(styleSheet.insertRule) {
styleSheet.insertRule(selector + '{' + styleString + '}', 0);
}
else if(styleSheet.addRule) {
styleSheet.addRule(selector, styleString, 0);
}
else lib.warn('addStyleRule failed');
};

lib.getTranslate = function(element) {

var re = /.*\btranslate\((\d*\.?\d*)[^\d]*(\d*\.?\d*)[^\d].*/,
Expand Down
5 changes: 3 additions & 2 deletions src/lib/notifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ var NOTEDATA = [];

/**
* notifier
* @param {object} gd figure Object
* @param {String} text The person's user name
* @param {Number} [delay=1000] The delay time in milliseconds
* or 'long' which provides 2000 ms delay time.
* @return {undefined} this function does not return a value
*/
module.exports = function(text, displayLength) {
module.exports = function(gd, text, displayLength) {
if(NOTEDATA.indexOf(text) !== -1) return;

NOTEDATA.push(text);
Expand All @@ -30,7 +31,7 @@ module.exports = function(text, displayLength) {
if(isNumeric(displayLength)) ts = displayLength;
else if(displayLength === 'long') ts = 3000;

var notifierContainer = d3.select('body')
var notifierContainer = d3.select(gd._document.body)
.selectAll('.plotly-notifier')
.data([0]);
notifierContainer.enter()
Expand Down
18 changes: 14 additions & 4 deletions src/plot_api/plot_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ var Lib = require('../lib');
var Events = require('../lib/events');
var Queue = require('../lib/queue');

var injectStyles = require('../css/plotcss_injector');

var Plots = require('../plots/plots');
var Fx = require('../plots/cartesian/graph_interact');

Expand Down Expand Up @@ -54,6 +56,14 @@ Plotly.plot = function(gd, data, layout, config) {

gd = getGraphDiv(gd);

// Get the document the graph div lives in, so we can make sure things like
// drag covers are attached to the correct document
gd._document = gd.ownerDocument || window.document;

// Inject the plot styles into the document where we're plotting, bails if
// already styled
injectStyles(gd);

// Events.init is idempotent and bails early if gd has already been init'd
Events.init(gd);

Expand Down Expand Up @@ -2541,12 +2551,12 @@ function plotAutoSize(gd, aobj) {
// embedded in an iframe - just take the full iframe size
// if we get to this point, with no aspect ratio restrictions
if(gd._context.fillFrame) {
newWidth = window.innerWidth;
newHeight = window.innerHeight;
newWidth = gd._document.defaultView.innerWidth;
newHeight = gd._document.defaultView.innerHeight;

// somehow we get a few extra px height sometimes...
// just hide it
document.body.style.overflow = 'hidden';
gd._document.body.style.overflow = 'hidden';
}
else if(isNumeric(context.frameMargins) && context.frameMargins > 0) {
var reservedMargins = calculateReservedMargins(gd._boundingBoxMargins),
Expand All @@ -2563,7 +2573,7 @@ function plotAutoSize(gd, aobj) {
// provide height and width for the container div,
// specify size in layout, or take the defaults,
// but don't enforce any ratio restrictions
computedStyle = window.getComputedStyle(gd);
computedStyle = gd._document.defaultView.getComputedStyle(gd);
newHeight = parseFloat(computedStyle.height) || fullLayout.height;
newWidth = parseFloat(computedStyle.width) || fullLayout.width;
}
Expand Down
3 changes: 0 additions & 3 deletions src/plotly.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ exports.Lib = require('./lib');
exports.util = require('./lib/svg_text_utils');
exports.Queue = require('./lib/queue');

// plot css
require('../build/plotcss');

// configuration
exports.MathJaxConfig = require('./fonts/mathjax_config');
exports.defaultConfig = require('./plot_api/plot_config');
Expand Down
2 changes: 1 addition & 1 deletion src/plots/cartesian/dragbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ module.exports = function dragBox(gd, plotinfo, x, y, w, h, ns, ew) {
dragTail(zoomMode);

if(SHOWZOOMOUTTIP && gd.data && gd._context.showTips) {
Lib.notifier('Double-click to<br>zoom back out', 'long');
Lib.notifier(gd, 'Double-click to<br>zoom back out', 'long');
SHOWZOOMOUTTIP = false;
}
}
Expand Down
Loading