Skip to content

Commit

Permalink
null computed style to avoid npe
Browse files Browse the repository at this point in the history
  • Loading branch information
hakimel authored and KroArtem committed Nov 20, 2016
1 parent 38c898a commit 88ce5a2
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions js/reveal.js
Original file line number Diff line number Diff line change
Expand Up @@ -866,15 +866,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 {
Expand Down

0 comments on commit 88ce5a2

Please sign in to comment.