diff options
author | Hakim El Hattab <hakim.elhattab@gmail.com> | 2016-07-04 14:46:46 +0200 |
---|---|---|
committer | Hakim El Hattab <hakim.elhattab@gmail.com> | 2016-07-04 14:46:46 +0200 |
commit | 304b0292be05d387947481eee7060f67ab808b5b (patch) | |
tree | 97d4939839a87f0688a59755871bdc2368b5856f /js | |
parent | ab2bb869a30cc10b2e4c064fd26c3790670b0c22 (diff) | |
download | fosdem-2018-presentation-304b0292be05d387947481eee7060f67ab808b5b.tar fosdem-2018-presentation-304b0292be05d387947481eee7060f67ab808b5b.tar.gz |
null computed style to avoid npe
Diffstat (limited to 'js')
-rw-r--r-- | js/reveal.js | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/js/reveal.js b/js/reveal.js index 473a616..b975ff4 100644 --- a/js/reveal.js +++ b/js/reveal.js @@ -855,15 +855,15 @@ // If this slide has a background color, add a class that // signals if it is light or dark. If the slide has no background // color, no class will be set - var computedBackgroundColor = window.getComputedStyle( element ).backgroundColor; - if( computedBackgroundColor ) { - var rgb = colorToRgb( computedBackgroundColor ); + var computedBackgroundStyle = window.getComputedStyle( element ); + if( computedBackgroundStyle && computedBackgroundStyle.backgroundColor ) { + var rgb = colorToRgb( computedBackgroundStyle.backgroundColor ); // Ignore fully transparent backgrounds. Some browsers return // rgba(0,0,0,0) when reading the computed background color of // an element with no background if( rgb && rgb.a !== 0 ) { - if( colorBrightness( computedBackgroundColor ) < 128 ) { + if( colorBrightness( computedBackgroundStyle.backgroundColor ) < 128 ) { slide.classList.add( 'has-dark-background' ); } else { |