]> source.dussan.org Git - svg.js.git/commitdiff
add error callback on image loading 508/head
authorAlexandre Peyron <alpeyron@gmail.com>
Tue, 12 Jul 2016 14:20:18 +0000 (16:20 +0200)
committerAlexandre Peyron <alpeyron@gmail.com>
Tue, 12 Jul 2016 14:20:18 +0000 (16:20 +0200)
src/image.js

index a0adf31de1222250d69bebaf6578e7ca5e891479..57bb3873cfb37625c987fbdbf0644247d72d42db 100644 (file)
@@ -38,6 +38,12 @@ SVG.Image = SVG.invent({
           })
       }
 
+      img.onerror = function(e){
+        if (typeof self._error === 'function'){
+            self._error.call(self, e)
+        }
+      }
+
       return this.attr('href', (img.src = this.src = url), SVG.xlink)
     }
     // Add loaded callback
@@ -45,6 +51,11 @@ SVG.Image = SVG.invent({
       this._loaded = loaded
       return this
     }
+
+  , error: function(error) {
+      this._error = error
+      return this
+    }
   }
   
   // Add parent method