aboutsummaryrefslogtreecommitdiffstats
path: root/src/image.js
diff options
context:
space:
mode:
authorAlexandre Peyron <alpeyron@gmail.com>2016-07-12 16:20:18 +0200
committerAlexandre Peyron <alpeyron@gmail.com>2016-07-12 16:20:18 +0200
commit774e4da62f9850a9609c234ae0e99fc165107a79 (patch)
tree04262b319321e7eb24250b515d545b74e97fce7c /src/image.js
parent399dd4a2b4a381a3652695a3ab31f7da72100110 (diff)
downloadsvg.js-774e4da62f9850a9609c234ae0e99fc165107a79.tar.gz
svg.js-774e4da62f9850a9609c234ae0e99fc165107a79.zip
add error callback on image loading
Diffstat (limited to 'src/image.js')
-rw-r--r--src/image.js11
1 files changed, 11 insertions, 0 deletions
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