From 774e4da62f9850a9609c234ae0e99fc165107a79 Mon Sep 17 00:00:00 2001 From: Alexandre Peyron Date: Tue, 12 Jul 2016 16:20:18 +0200 Subject: add error callback on image loading --- src/image.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/image.js b/src/image.js index a0adf31..57bb387 100644 --- a/src/image.js +++ b/src/image.js @@ -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 -- cgit v1.2.3