diff options
author | Wout <wout@impinc.co.uk> | 2014-06-19 10:56:49 +0200 |
---|---|---|
committer | Wout <wout@impinc.co.uk> | 2014-06-19 10:56:49 +0200 |
commit | f47dddcb601cccbd374f100c4441d7d0c151a15b (patch) | |
tree | a51e483fb7e3e442fe8e58d2a93b4a2265695c2d | |
parent | 45adf7dbbff51217dfc580440487ea0d21e8df7a (diff) | |
parent | e683b0c833f489f1ff000f1dd5159e4cad76e596 (diff) | |
download | svg.js-f47dddcb601cccbd374f100c4441d7d0c151a15b.tar.gz svg.js-f47dddcb601cccbd374f100c4441d7d0c151a15b.zip |
Merge pull request #216 from shabegger/master
Fixed Infinite Loop
-rwxr-xr-x | src/viewbox.js | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/viewbox.js b/src/viewbox.js index aec60a3..5f13c3e 100755 --- a/src/viewbox.js +++ b/src/viewbox.js @@ -5,6 +5,8 @@ SVG.ViewBox = function(element) { , hm = 1 /* height multiplier */ , box = element.bbox() , view = (element.attr('viewBox') || '').match(/-?[\d\.]+/g) + , wElement = element + , hElement = element /* get dimensions of current node */ width = new SVG.Number(element.width()) @@ -13,11 +15,13 @@ SVG.ViewBox = function(element) { /* find nearest non-percentual dimensions */ while (width.unit == '%') { wm *= width.value - width = new SVG.Number(element instanceof SVG.Doc ? element.parent.offsetWidth : element.width()) + width = new SVG.Number(wElement instanceof SVG.Doc ? wElement.parent.offsetWidth : wElement.parent.width()) + wElement = wElement.parent } while (height.unit == '%') { hm *= height.value - height = new SVG.Number(element instanceof SVG.Doc ? element.parent.offsetHeight : element.height()) + height = new SVG.Number(hElement instanceof SVG.Doc ? hElement.parent.offsetHeight : hElement.parent.height()) + hElement = hElement.parent } /* ensure defaults */ |