Skip to content
This repository has been archived by the owner on Mar 6, 2019. It is now read-only.

Fix for auto width/height <rect> elements #26

Open
wants to merge 1 commit into
base: gh-pages
Choose a base branch
from
Open
Changes from all commits
Commits
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: 8 additions & 0 deletions svg-crowbar-2.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,13 @@
function setInlineStyles(svg, emptySvgDeclarationComputed) {

function explicitlySetStyle (element) {
var clientRect = { width: "auto", height: "auto"};
var cSSStyleDeclarationComputed = getComputedStyle(element);
var i, len, key, value;
var computedStyleStr = "";
if (element.tagName === "rect") {
clientRect = element.getBoundingClientRect();
}
for (i=0, len=cSSStyleDeclarationComputed.length; i<len; i++) {
key=cSSStyleDeclarationComputed[i];
value=cSSStyleDeclarationComputed.getPropertyValue(key);
Expand All @@ -222,6 +226,10 @@
}
}
element.setAttribute('style', computedStyleStr);
if (element.tagName === "rect") {
element.style["width"] = clientRect.width;
element.style["height"] = clientRect.height;
}
}
function traverse(obj){
var tree = [];
Expand Down