avoid errors in old ie from code highlighting

This commit is contained in:
Hakim El Hattab 2013-04-28 14:12:31 -04:00
parent 78c4bf420e
commit f210e7b1b5

View File

@ -1,6 +1,11 @@
// START CUSTOM REVEAL.JS INTEGRATION // START CUSTOM REVEAL.JS INTEGRATION
(function() { (function() {
[].slice.call( document.querySelectorAll( 'pre code' ) ).forEach( function( element ) { if( typeof window.addEventListener === 'function' ) {
var hljs_nodes = document.querySelectorAll( 'pre code' );
for( var i = 0, len = hljs_nodes.length; i < len; i++ ) {
var element = hljs_nodes[i];
// trim whitespace if data-trim attribute is present // trim whitespace if data-trim attribute is present
if( element.hasAttribute( 'data-trim' ) && typeof element.innerHTML.trim === 'function' ) { if( element.hasAttribute( 'data-trim' ) && typeof element.innerHTML.trim === 'function' ) {
element.innerHTML = element.innerHTML.trim(); element.innerHTML = element.innerHTML.trim();
@ -10,7 +15,8 @@
element.addEventListener( 'focusout', function( event ) { element.addEventListener( 'focusout', function( event ) {
hljs.highlightBlock( event.currentTarget ); hljs.highlightBlock( event.currentTarget );
}, false ); }, false );
} ); }
}
})(); })();
// END CUSTOM REVEAL.JS INTEGRATION // END CUSTOM REVEAL.JS INTEGRATION