From 0cecead44bc5a68eefda089cdb0702e670e1e98e Mon Sep 17 00:00:00 2001 From: Addy Osmani Date: Thu, 19 Jun 2014 14:56:27 +0100 Subject: [PATCH] Minor changes to toggling --- app/styleguide/index.html | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/app/styleguide/index.html b/app/styleguide/index.html index 79637d50..cabb1840 100644 --- a/app/styleguide/index.html +++ b/app/styleguide/index.html @@ -1165,16 +1165,19 @@ 'use strict'; var snippetToggle = document.querySelector('#snippet-toggle'); + var snippets; snippetToggle.addEventListener('click', function() { - var snippets = document.querySelectorAll('.auto-gen-code-snippet'); - for(var i = 0; i < snippets.length; i++) { - snippets[i].classList.toggle('auto-gen-code-visible'); - }; + if(snippets){ + for(var i = 0; i < snippets.length; i++) { + snippets[i].classList.toggle('auto-gen-code-visible'); + }; + } }, true); window.onload = function() { createCodeSamples(); + snippets = document.querySelectorAll('.auto-gen-code-snippet'); } function createCodeSamples() {