null and type check what comes through postmessage
This commit is contained in:
parent
167400ee8b
commit
53238c47ce
13
js/reveal.js
13
js/reveal.js
|
@ -575,11 +575,16 @@ var Reveal = (function(){
|
||||||
|
|
||||||
if( config.postMessage ) {
|
if( config.postMessage ) {
|
||||||
window.addEventListener( 'message', function ( event ) {
|
window.addEventListener( 'message', function ( event ) {
|
||||||
var data = JSON.parse( event.data );
|
var data = event.data;
|
||||||
var method = Reveal[data.method];
|
|
||||||
|
|
||||||
if( typeof method === 'function' ) {
|
// Make sure we're dealing with JSON
|
||||||
method.apply( Reveal, data.args );
|
if( data.charAt( 0 ) === '{' && data.charAt( data.length - 1 ) === '}' ) {
|
||||||
|
data = JSON.parse( data );
|
||||||
|
|
||||||
|
// Check if the requested method can be found
|
||||||
|
if( data.method && typeof Reveal[data.method] === 'function' ) {
|
||||||
|
Reveal[data.method].apply( Reveal, data.args );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}, false );
|
}, false );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user