From 661afca98f82f705d8891844134001027fb13ec6 Mon Sep 17 00:00:00 2001 From: Jonathan Puckey Date: Sat, 10 Nov 2012 15:45:11 +0100 Subject: [PATCH] Svg Importer: getValue: make sure the attribute exists first. --- examples/SVG Import/Symbols.html | 4 ++-- examples/SVG Import/Viewbox.html | 38 ++++++++++++++++++++++++++++++++ src/svg/SvgImport.js | 5 ++++- 3 files changed, 44 insertions(+), 3 deletions(-) create mode 100644 examples/SVG Import/Viewbox.html diff --git a/examples/SVG Import/Symbols.html b/examples/SVG Import/Symbols.html index 0d316e1e..965a7c7f 100644 --- a/examples/SVG Import/Symbols.html +++ b/examples/SVG Import/Symbols.html @@ -11,7 +11,7 @@ + width="595px" height="841px" viewBox="0 0 595.28 841.89" enable-background="new 0 0 595.28 841.89" xml:space="preserve"> @@ -20,6 +20,6 @@ - + \ No newline at end of file diff --git a/examples/SVG Import/Viewbox.html b/examples/SVG Import/Viewbox.html new file mode 100644 index 00000000..afcea025 --- /dev/null +++ b/examples/SVG Import/Viewbox.html @@ -0,0 +1,38 @@ + + + + + Viewbox 1 + + + + + + + Example ViewBox - uses the viewBox + attribute to automatically create an initial user coordinate + system which causes the graphic to scale to fit into the + viewport no matter what size the viewport is. + + + + + + + + + + Stretch to fit + + + + + \ No newline at end of file diff --git a/src/svg/SvgImport.js b/src/svg/SvgImport.js index 8abe6052..c4e83f82 100644 --- a/src/svg/SvgImport.js +++ b/src/svg/SvgImport.js @@ -26,7 +26,10 @@ new function() { // index is option, and if passed, causes a lookup in a list. function getValue(svg, key, allowNull, index) { - var base = svg[key].baseVal, + var attribute = svg[key]; + if (!attribute) + return; + var base = attribute.baseVal, value = index !== undefined ? index < base.numberOfItems ? base.getItem(index).value : null : base.value;