going to version 0.1.1 with noConflict

This commit is contained in:
Jeremy Ashkenas
2009-10-28 12:37:55 -04:00
parent 195a0f0908
commit 6d52832a73
4 changed files with 33 additions and 6 deletions

View File

@@ -102,11 +102,11 @@
<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 @@
<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 @@ _.isUndefined(window.missingVariable);
</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 File

@@ -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;

2
underscore-min.js vendored

File diff suppressed because one or more lines are too long

View File

@@ -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;