Skip to content

Commit d7d64e8

Browse files
chrome image export weird bug hard fix
1 parent d4f4320 commit d7d64e8

File tree

3 files changed

+14
-12
lines changed

3 files changed

+14
-12
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "CacheUMLExplorer",
3-
"version": "0.13.1",
3+
"version": "0.13.2",
44
"description": "An UML Class explorer for InterSystems Caché",
55
"directories": {
66
"test": "test"

web/index.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,5 @@ <h2 id="methodLabel"></h2>
8080
</div>
8181
</div>
8282
</div>
83-
<canvas id="canvas" width="1000px" height="600px"></canvas>
8483
</body>
8584
</html>

web/jsLib/ImageExporter.js

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ var enableSVGDownload = function (classView) {
1616
function getSources(doc, emptySvgDeclarationComputed) {
1717

1818
var svgInfo = [],
19-
svgs = doc.querySelectorAll("svg");
19+
svgs = doc.querySelectorAll("#svgContainer > svg");
2020

2121
[].forEach.call(svgs, function (svg) {
2222

@@ -67,17 +67,15 @@ var enableSVGDownload = function (classView) {
6767

6868
document.getElementById("button.downloadSVG").addEventListener("click", function () {
6969

70-
var emptySvg = window.document.createElementNS(prefix.svg, 'svg'),
71-
emptySvgDeclarationComputed = getComputedStyle(emptySvg),
72-
source = getSources(document, emptySvgDeclarationComputed)[0];
73-
70+
var emptySvg = document.createElementNS(prefix.svg, 'svg');
71+
document.body.appendChild(emptySvg);
72+
var emptySvgDeclarationComputed = getComputedStyle(emptySvg);
73+
var source = getSources(document, emptySvgDeclarationComputed)[0];
7474
var filename = (classView || {}).SELECTED_NAME || "classDiagram";
75-
7675
var img = new Image();
77-
var url = window.URL.createObjectURL(new Blob(source.source, { "type" : 'image/svg+xml;charset=utf-8'/*"text\/xml"*/ }));
78-
79-
var canvas = document.createElement('canvas');
80-
var ctx = canvas.getContext('2d');
76+
var url = window.URL.createObjectURL(new Blob(source.source, { "type" : 'image/svg+xml;charset=utf-8' }));
77+
var canvas = document.createElement("canvas");
78+
var ctx = canvas.getContext("2d");
8179
canvas.setAttribute("width", source.width);
8280
canvas.setAttribute("height", source.height);
8381
document.body.appendChild(canvas);
@@ -92,6 +90,7 @@ var enableSVGDownload = function (classView) {
9290
a.click();
9391
setTimeout(function () {
9492
a.parentNode.removeChild(a);
93+
document.body.removeChild(emptySvg);
9594
canvas.parentNode.removeChild(canvas);
9695
window.URL.revokeObjectURL(url);
9796
}, 10);
@@ -110,6 +109,10 @@ var enableSVGDownload = function (classView) {
110109
for (i=0, len=cSSStyleDeclarationComputed.length; i<len; i++) {
111110
key=cSSStyleDeclarationComputed[i];
112111
value=cSSStyleDeclarationComputed.getPropertyValue(key);
112+
113+
// weird fix for weird bug in chrome: css rewrites w/h tag attributes!
114+
if (value === "auto" && (key === "width" || key === "height")) continue;
115+
113116
if (value!==emptySvgDeclarationComputed.getPropertyValue(key)) {
114117
computedStyleStr+=key+":"+value+";";
115118
}

0 commit comments

Comments
 (0)