aboutsummaryrefslogtreecommitdiff
path: root/plugin/highlight
diff options
context:
space:
mode:
authorHakim El Hattab <hakim.elhattab@gmail.com>2013-04-28 14:12:31 -0400
committerHakim El Hattab <hakim.elhattab@gmail.com>2013-04-28 14:12:31 -0400
commitf210e7b1b5f0dceb610cf0355b689ed6a16624e1 (patch)
treebefb0ea9619f7990c0bd295f688ed8a066a00d23 /plugin/highlight
parent78c4bf420e6b2b441d7072e8e612d15691278749 (diff)
downloadfreenode-live-2017-presentation-f210e7b1b5f0dceb610cf0355b689ed6a16624e1.tar
freenode-live-2017-presentation-f210e7b1b5f0dceb610cf0355b689ed6a16624e1.tar.gz
avoid errors in old ie from code highlighting
Diffstat (limited to 'plugin/highlight')
-rw-r--r--plugin/highlight/highlight.js26
1 files changed, 16 insertions, 10 deletions
diff --git a/plugin/highlight/highlight.js b/plugin/highlight/highlight.js
index af769db..6756359 100644
--- a/plugin/highlight/highlight.js
+++ b/plugin/highlight/highlight.js
@@ -1,16 +1,22 @@
// START CUSTOM REVEAL.JS INTEGRATION
(function() {
- [].slice.call( document.querySelectorAll( 'pre code' ) ).forEach( function( element ) {
- // trim whitespace if data-trim attribute is present
- if( element.hasAttribute( 'data-trim' ) && typeof element.innerHTML.trim === 'function' ) {
- element.innerHTML = element.innerHTML.trim();
- }
+ 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];
- // re-highlight when focus is lost (for edited code)
- element.addEventListener( 'focusout', function( event ) {
- hljs.highlightBlock( event.currentTarget );
- }, false );
- } );
+ // trim whitespace if data-trim attribute is present
+ if( element.hasAttribute( 'data-trim' ) && typeof element.innerHTML.trim === 'function' ) {
+ element.innerHTML = element.innerHTML.trim();
+ }
+
+ // re-highlight when focus is lost (for edited code)
+ element.addEventListener( 'focusout', function( event ) {
+ hljs.highlightBlock( event.currentTarget );
+ }, false );
+ }
+ }
})();
// END CUSTOM REVEAL.JS INTEGRATION