aboutsummaryrefslogtreecommitdiffstats
path: root/src/svg.js
diff options
context:
space:
mode:
authorwout <wout@impinc.co.uk>2013-02-15 15:42:11 +0100
committerwout <wout@impinc.co.uk>2013-02-15 15:42:11 +0100
commit41db95ada5a390d1add43c63ad831fccd9c69b90 (patch)
treef66fe177299d6cdcf5e0ae1f8a4f9319959bc206 /src/svg.js
parent3ebe05f1a91ba05b6eebfefae1358dab0381f23b (diff)
downloadsvg.js-41db95ada5a390d1add43c63ad831fccd9c69b90.tar.gz
svg.js-41db95ada5a390d1add43c63ad831fccd9c69b90.zip
Added support test
Diffstat (limited to 'src/svg.js')
-rw-r--r--src/svg.js25
1 files changed, 17 insertions, 8 deletions
diff --git a/src/svg.js b/src/svg.js
index 9306232..d8088be 100644
--- a/src/svg.js
+++ b/src/svg.js
@@ -8,26 +8,35 @@
// Shortcut for creating a svg document
this.svg = function(element) {
- return new SVG.Doc(element);
+ if (SVG.supported)
+ return new SVG.Doc(element);
};
// The main wrapping element
this.SVG = {
/* default namespaces */
- ns: 'http://www.w3.org/2000/svg',
- xlink: 'http://www.w3.org/1999/xlink',
+ ns: 'http://www.w3.org/2000/svg'
+, xlink: 'http://www.w3.org/1999/xlink'
/* defs id sequence */
- did: 0,
+, did: 0
// Method for element creation
- create: function(element) {
+, create: function(element) {
return document.createElementNS(this.ns, element);
- },
+ }
// Method for extending objects
- extend: function(object, module) {
+, extend: function(object, module) {
for (var key in module)
object.prototype[key] = module[key];
}
-}; \ No newline at end of file
+};
+
+// svg support test
+SVG.supported = (function() {
+ return !! document.createElementNS &&
+ !! document.createElementNS(SVG.ns,'svg').createSVGRect;
+})();
+
+if (!SVG.supported) return false; \ No newline at end of file