Skip to content

Commit

Permalink
Avoid IE8 error on canvas
Browse files Browse the repository at this point in the history
Signed-off-by: Michael M Slusarz <slusarz@horde.org>
  • Loading branch information
joaomachado authored and slusarz committed Apr 29, 2014
1 parent fd7c66b commit 9f9f54e
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions imp/js/compose-dimp.js
Expand Up @@ -824,12 +824,15 @@ var DimpCompose = {

if (opts.icon) {
canvas = new Element('CANVAS', { height: '16px', width: '16px' });
li.insert(canvas);
img = new Image();
img.onload = function() {
canvas.getContext('2d').drawImage(img, 0, 0, 16, 16);
};
img.src = opts.icon;
// IE8 doesn't support canvas
if (canvas.getContext) {
li.insert(canvas);
img = new Image();
img.onload = function() {
canvas.getContext('2d').drawImage(img, 0, 0, 16, 16);
};
img.src = opts.icon;
}
}

li.insert(span);
Expand Down

0 comments on commit 9f9f54e

Please sign in to comment.