Unified · Split
| @@ -28,12 +28,19 @@ withImage = (url, action) -> · 27 unmodified lines | ||
| 28 | 28 | currentSlug = doc.slug |
| 29 | 29 | return |
| 30 | 30 | |
| 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 | |
| 32 | 39 | |
| 33 | 40 | bgUrl = app.config.favicon_spritesheet |
| 34 | 41 | 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))) | |
| 37 | 44 | |
| 38 | 45 | withImage(bgUrl, (docImg) -> |
| 39 | 46 | withImage(defaultUrl, (defaultImg) -> |