Update vendors.

Former-commit-id: e109c9ffd436610d066493b07bd38293e1ec01a7
This commit is contained in:
John-David Dalton
2012-11-19 20:54:23 -08:00
parent 4a99c2e928
commit 2639cc6138
6 changed files with 45 additions and 5 deletions

View File

@@ -367,7 +367,7 @@
// If we're "wait"-ing to set changed attributes, validate early.
if (options.wait) {
if (!this._validate(attrs, options)) return false;
if (attrs && !this._validate(attrs, options)) return false;
current = _.clone(this.attributes);
}
@@ -1204,7 +1204,7 @@
var delegateEventSplitter = /^(\S+)\s*(.*)$/;
// List of view options to be merged as properties.
var viewOptions = ['model', 'collection', 'el', 'id', 'attributes', 'className', 'tagName'];
var viewOptions = ['model', 'collection', 'el', 'id', 'attributes', 'className', 'tagName', 'events'];
// Set up all inheritable **Backbone.View** properties and methods.
_.extend(View.prototype, Events, {

View File

@@ -99,7 +99,7 @@ $(document).ready(function() {
equal(model.url(), '/nested/1/collection/2');
});
test("clone", 8, function() {
test("clone", 10, function() {
var a = new Backbone.Model({ 'foo': 1, 'bar': 2, 'baz': 3});
var b = a.clone();
equal(a.get('foo'), 1);
@@ -111,6 +111,12 @@ $(document).ready(function() {
a.set({foo : 100});
equal(a.get('foo'), 100);
equal(b.get('foo'), 1, "Changing a parent attribute does not change the clone.");
var foo = new Backbone.Model({p: 1});
var bar = new Backbone.Model({p: 2});
bar.set(foo.clone(), {unset: true});
equal(foo.get('p'), 1);
equal(bar.get('p'), undefined);
});
test("isNew", 6, function() {

View File

@@ -331,4 +331,28 @@ $(document).ready(function() {
ok(view.$el.is('p:has(a)'));
});
test("events passed in options", 2, function() {
var counter = 0;
var View = Backbone.View.extend({
el: '<p><a id="test"></a></p>',
increment: function() {
counter++;
}
});
var view = new View({events:{'click #test':'increment'}});
var view2 = new View({events:function(){
return {'click #test':'increment'};
}});
view.$('#test').trigger('click');
view2.$('#test').trigger('click');
equal(counter, 2);
view.$('#test').trigger('click');
view2.$('#test').trigger('click');
equal(counter, 4);
});
});

View File

@@ -348,6 +348,11 @@ $(document).ready(function() {
var array = [{}];
_.groupBy(array, function(value, index, obj){ ok(obj === array); });
var array = [1, 2, 1, 2, 3];
var grouped = _.groupBy(array);
equal(grouped['1'].length, 2);
equal(grouped['3'].length, 1);
});
test('countBy', function() {
@@ -372,6 +377,11 @@ $(document).ready(function() {
var array = [{}];
_.countBy(array, function(value, index, obj){ ok(obj === array); });
var array = [1, 2, 1, 2, 3];
var grouped = _.countBy(array);
equal(grouped['1'], 2);
equal(grouped['3'], 1);
});
test('sortedIndex', function() {

File diff suppressed because one or more lines are too long

View File

@@ -316,7 +316,7 @@
// An internal function used for aggregate "group by" operations.
var group = function(obj, value, context, behavior) {
var result = {};
var iterator = lookupIterator(value);
var iterator = lookupIterator(value || _.identity);
each(obj, function(value, index) {
var key = iterator.call(context, value, index, obj);
behavior(result, key, value);