Browse Source

Fix various favicon-related Sentry issues

Jasper van Merle 6 years ago
parent
commit
782429ca02
1 changed files with 10 additions and 3 deletions
  1. 10 3
      assets/javascripts/lib/favicon.coffee

+ 10 - 3
assets/javascripts/lib/favicon.coffee

@@ -28,12 +28,19 @@ withImage = (url, action) ->
     currentSlug = doc.slug
     currentSlug = doc.slug
     return
     return
 
 
-  styles = window.getComputedStyle($("._icon-#{doc.slug.split('~')[0]}"), ':before')
+  iconEl = $("._icon-#{doc.slug.split('~')[0]}")
+  return if iconEl == null
+
+  styles = window.getComputedStyle(iconEl, ':before')
+
+  backgroundPositionX = styles['background-position-x']
+  backgroundPositionY = styles['background-position-y']
+  return if backgroundPositionX == undefined || backgroundPositionY == undefined
 
 
   bgUrl = app.config.favicon_spritesheet
   bgUrl = app.config.favicon_spritesheet
   sourceSize = 16
   sourceSize = 16
-  sourceX = Math.abs(parseInt(styles['background-position-x'].slice(0, -2)))
-  sourceY = Math.abs(parseInt(styles['background-position-y'].slice(0, -2)))
+  sourceX = Math.abs(parseInt(backgroundPositionX.slice(0, -2)))
+  sourceY = Math.abs(parseInt(backgroundPositionY.slice(0, -2)))
 
 
   withImage(bgUrl, (docImg) ->
   withImage(bgUrl, (docImg) ->
     withImage(defaultUrl, (defaultImg) ->
     withImage(defaultUrl, (defaultImg) ->