History

Fix various favicon-related Sentry issues

Jasper van Merle committed 7 years ago

Commit 782429c1 parent fa2fab71 file · +10 −3Browse files

Showing the changes to assets/javascripts (1 of 1 file). Show all

Unified · Split

assets/javascripts/lib/favicon.coffee+10−3
@@ -28,12 +28,19 @@ withImage = (url, action) -> · 27 unmodified lines
2828 currentSlug = doc.slug
2929 return
3030
31− styles = window.getComputedStyle($("._icon-#{doc.slug.split('~')[0]}"), ':before')
31+ iconEl = $("._icon-#{doc.slug.split('~')[0]}")
32+ return if iconEl == null
33+
34+ styles = window.getComputedStyle(iconEl, ':before')
35+
36+ backgroundPositionX = styles['background-position-x']
37+ backgroundPositionY = styles['background-position-y']
38+ return if backgroundPositionX == undefined || backgroundPositionY == undefined
3239
3340 bgUrl = app.config.favicon_spritesheet
3441 sourceSize = 16
35− sourceX = Math.abs(parseInt(styles['background-position-x'].slice(0, -2)))
36− sourceY = Math.abs(parseInt(styles['background-position-y'].slice(0, -2)))
42+ sourceX = Math.abs(parseInt(backgroundPositionX.slice(0, -2)))
43+ sourceY = Math.abs(parseInt(backgroundPositionY.slice(0, -2)))
3744
3845 withImage(bgUrl, (docImg) ->
3946 withImage(defaultUrl, (defaultImg) ->