Permalink
Browse files

going to version 0.1.1 with noConflict

  • Loading branch information...
1 parent 195a0f0 commit 6d52832a73dcedffd8838ebe0d12fc1d4841588b @jashkenas jashkenas committed Oct 28, 2009
Showing with 33 additions and 6 deletions.
  1. +13 −3 index.html
  2. +6 −0 test/utility.js
  3. +1 −1 underscore-min.js
  4. +13 −2 underscore.js
View
@@ -102,11 +102,11 @@ <h2>Downloads <i style="padding-left: 12px; font-size:12px;">(Right-click, and u
<p>
<table>
<tr>
- <td><a href="underscore.js">Development Version</a></td>
+ <td><a href="underscore.js">Development Version (0.1.1)</a></td>
<td><i>16kb, Uncompressed with Comments</i></td>
</tr>
<tr>
- <td><a href="underscore-min.js">Production Version</a></td>
+ <td><a href="underscore-min.js">Production Version (0.1.1)</a></td>
<td><i>4kb, Packed and Gzipped</i></td>
</tr>
</table>
@@ -151,7 +151,8 @@ <h2>Table of Contents</h2>
<p>
<b>Utility</b>
<br />
- <span class="methods"><a href="#uniqueId">uniqueId</a>, <a href="#template">template</a></span>
+ <span class="methods"><a href="#noConflict">noConflict</a>,
+ <a href="#uniqueId">uniqueId</a>, <a href="#template">template</a></span>
</p>
<div id="documentation">
@@ -649,6 +650,15 @@ <h2>Object Functions</h2>
</pre>
<h2>Utility Functions</h2>
+
+ <p id="noConflict">
+ <b class="method_name">noConflict</b><code>_.noConflict()</code>
+ <br />
+ Give control of the "_" variable back to its previous owner. Returns
+ a reference to the <b>Underscore</b> object.
+ </p>
+ <pre>
+var underscore = _.noConflict();</pre>
<p id="uniqueId">
<b class="method_name">uniqueId</b><code>_.uniqueId([prefix])</code>
View
@@ -1,6 +1,12 @@
$(document).ready(function() {
module("Utility functions (uniqueId, template)");
+
+ test("utility: noConflict", function() {
+ var underscore = _.noConflict();
+ ok(underscore.isUndefined(_), "The '_' variable has been returned to its previous state.");
+ window._ = underscore;
+ });
test("utility: uniqueId", function() {
var ids = [], i = 0;
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -5,9 +5,11 @@
// Oliver Steele's Functional, And John Resig's Micro-Templating.
// For all details and documentation:
// http://documentcloud.github.com/underscore/
-window._ = {
+window.Underscore = {
- VERSION : '0.1.0',
+ VERSION : '0.1.1',
+
+ PREVIOUS_UNDERSCORE : window._,
/*------------------------ Collection Functions: ---------------------------*/
@@ -387,6 +389,13 @@ window._ = {
/* -------------------------- Utility Functions: -------------------------- */
+ // Run Underscore.js in noConflict mode, returning the '_' variable to its
+ // previous owner. Returns a reference to the Underscore object.
+ noConflict : function() {
+ window._ = Underscore.PREVIOUS_UNDERSCORE;
+ return this;
+ },
+
// Generate a unique integer id (unique within the entire client session).
// Useful for temporary DOM ids.
uniqueId : function(prefix) {
@@ -413,3 +422,5 @@ window._ = {
}
};
+
+window._ = Underscore;

0 comments on commit 6d52832

Please sign in to comment.