Skip to content

Commit 83b3d64

Browse files
committed
Revert "Cache DOM nodes and selected d3 node"
This reverts commit 29abb5d.
1 parent 6653e71 commit 83b3d64

File tree

2 files changed

+11
-18
lines changed

2 files changed

+11
-18
lines changed

src/components/drawing/index.js

+10-15
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,6 @@ drawing.makeTester = function(gd) {
589589
// always returns a copy of the bbox, so the caller can modify it safely
590590
var savedBBoxes = [],
591591
maxSavedBBoxes = 10000;
592-
593592
drawing.bBox = function(node) {
594593
// cache elements we've already measured so we don't have to
595594
// remeasure the same thing many times
@@ -598,36 +597,32 @@ drawing.bBox = function(node) {
598597
return Lib.extendFlat({}, savedBBoxes[saveNum.value]);
599598
}
600599

601-
if(!drawing.test3) {
602-
drawing.test3 = d3.select('#js-plotly-tester');
603-
drawing.tester = drawing.test3.node();
604-
}
600+
var test3 = d3.select('#js-plotly-tester'),
601+
tester = test3.node();
605602

606603
// copy the node to test into the tester
607604
var testNode = node.cloneNode(true);
608-
drawing.tester.appendChild(testNode);
605+
tester.appendChild(testNode);
609606
// standardize its position... do we really want to do this?
610607
d3.select(testNode).attr({
611608
x: 0,
612609
y: 0,
613610
transform: ''
614611
});
615612

616-
var testRect = testNode.getBoundingClientRect();
617-
if(!drawing.refRect) {
618-
drawing.refRect = drawing.test3.select('.js-reference-point')
613+
var testRect = testNode.getBoundingClientRect(),
614+
refRect = test3.select('.js-reference-point')
619615
.node().getBoundingClientRect();
620-
}
621616

622-
drawing.tester.removeChild(testNode);
617+
tester.removeChild(testNode);
623618

624619
var bb = {
625620
height: testRect.height,
626621
width: testRect.width,
627-
left: testRect.left - drawing.refRect.left,
628-
top: testRect.top - drawing.refRect.top,
629-
right: testRect.right - drawing.refRect.left,
630-
bottom: testRect.bottom - drawing.refRect.top
622+
left: testRect.left - refRect.left,
623+
top: testRect.top - refRect.top,
624+
right: testRect.right - refRect.left,
625+
bottom: testRect.bottom - refRect.top
631626
};
632627

633628
// make sure we don't have too many saved boxes,

src/lib/svg_text_utils.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ var stringMappings = require('../constants/string_mappings');
1919

2020
// Append SVG
2121

22-
var parser = new DOMParser();
23-
2422
d3.selection.prototype.appendSVG = function(_svgString) {
2523
var skeleton = [
2624
'<svg xmlns="', xmlnsNamespaces.svg, '" ',
@@ -29,7 +27,7 @@ d3.selection.prototype.appendSVG = function(_svgString) {
2927
'</svg>'
3028
].join('');
3129

32-
var dom = parser.parseFromString(skeleton, 'application/xml'),
30+
var dom = new DOMParser().parseFromString(skeleton, 'application/xml'),
3331
childNode = dom.documentElement.firstChild;
3432

3533
while(childNode) {

0 commit comments

Comments
 (0)