Permalink
Browse files

Fixed jshint and used documentFragment to speed up

  • Loading branch information...
1 parent ef9b802 commit 747cd7b9578ce28e7b4f1cbbbb4f7967c08dde29 @ralt committed May 10, 2012
Showing with 6 additions and 2 deletions.
  1. +6 −2 js/impress.js
View
8 js/impress.js
@@ -569,14 +569,15 @@
// @see http://stackoverflow.com/a/1026087/851498
var capitalize = function( str ) {
return str.charAt(0).toUpperCase() + str.slice(1);
- }
+ };
// `showMenu` API function creates the menu
// It defines the names of each entry by the id capitalized.
var showMenu = function() {
// Create the menu wrapper and the element that will be cloned
// for each entry.
var menu = document.createElement('div'),
+ frag = document.createDocumentFragment(),
el = document.createElement('div');
// Apply some classes
@@ -611,9 +612,12 @@
}( index ));
// And append the new element to the menu
- menu.appendChild(newEl);
+ frag.appendChild(newEl);
});
+ // Add the frag to the menu
+ menu.appendChild(frag);
+
// And append the menu to the body.
// Appending it to #impress would mess things up, since
// `position: absolute` wouldn't work anymore in it.

0 comments on commit 747cd7b

Please sign in to comment.