Skip to content

Commit 685b833

Browse files
committed
Merge branch 'dev' of github.com:hakimel/reveal.js into flexbox
2 parents dfcd608 + 53238c4 commit 685b833

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

js/reveal.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -575,11 +575,16 @@ var Reveal = (function(){
575575

576576
if( config.postMessage ) {
577577
window.addEventListener( 'message', function ( event ) {
578-
var data = JSON.parse( event.data );
579-
var method = Reveal[data.method];
578+
var data = event.data;
580579

581-
if( typeof method === 'function' ) {
582-
method.apply( Reveal, data.args );
580+
// Make sure we're dealing with JSON
581+
if( data.charAt( 0 ) === '{' && data.charAt( data.length - 1 ) === '}' ) {
582+
data = JSON.parse( data );
583+
584+
// Check if the requested method can be found
585+
if( data.method && typeof Reveal[data.method] === 'function' ) {
586+
Reveal[data.method].apply( Reveal, data.args );
587+
}
583588
}
584589
}, false );
585590
}

0 commit comments

Comments
 (0)