Skip to content

Commit

Permalink
added IIFE wrappers to avoid global variables
Browse files Browse the repository at this point in the history
this essentially creates self-contained modules

cf.
http://benalman.com/news/2010/11/immediately-invoked-function-expression/
  • Loading branch information
FND committed Sep 14, 2013
1 parent 2dbe86f commit 7b6b753
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/main.js
@@ -1,3 +1,5 @@
(function() {

var contacts = jQuery("ul.contacts");
var filterField = jQuery('<input type="search" />').insertBefore(contacts).
on("keyup", onFilter);
Expand All @@ -21,3 +23,5 @@ function onFilter(ev) {
}
});
}

}());
4 changes: 4 additions & 0 deletions test/test_filtering.js
@@ -1,3 +1,5 @@
(function() {

QUnit.module("contacts filtering");

QUnit.asyncTest("filtering by initials", function() {
Expand Down Expand Up @@ -25,3 +27,5 @@ function extractNames(items) {
});
return Array.prototype.slice.call(names);
}

}());

0 comments on commit 7b6b753

Please sign in to comment.