summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorStephen Habegger <qshobbes@live.com>2014-06-16 07:38:48 -0500
committerStephen Habegger <qshobbes@live.com>2014-06-16 07:38:48 -0500
commite683b0c833f489f1ff000f1dd5159e4cad76e596 (patch)
treec7439aab680351d895a1136dd14b0f74c88ac79c /src
parentadad1d062678522e684bfe5216f63a3f400bd3c9 (diff)
downloadsvg.js-e683b0c833f489f1ff000f1dd5159e4cad76e596.tar.gz
svg.js-e683b0c833f489f1ff000f1dd5159e4cad76e596.zip
Fixed Infinite Loop
Fixed infinite loop in ViewBox when element has a percentage width/height.
Diffstat (limited to 'src')
-rwxr-xr-xsrc/viewbox.js8
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 */