Skip to content

Commit

Permalink
Merge branch 'master' of github.com:component/model
Browse files Browse the repository at this point in the history
  • Loading branch information
tj committed Jan 5, 2013
2 parents 8f7c90e + b46680e commit 1b4aba3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 3 additions & 3 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ function createModel(name) {

function model(attrs) {
if (!(this instanceof model)) return new model(attrs);
attrs = attrs || {};
this._callbacks = {};
this.attrs = {};
this.dirty = {};
if (attrs) this.set(attrs);
this.attrs = attrs;
this.dirty = attrs;
}

// mixin emitte
Expand Down
4 changes: 3 additions & 1 deletion lib/static.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ exports.attr = function(name, options){
var prev = this.attrs[name];
this.dirty[name] = val;
this.attrs[name] = val;
this.model.emit('change', this, name, val, prev);
this.model.emit('change ' + name, this, val, prev);
this.emit('change', name, val, prev);
this.emit('change ' + name, val, prev);
return this;
Expand Down Expand Up @@ -149,4 +151,4 @@ exports.get = function(id, fn){

function error(res) {
return new Error('got ' + res.status + ' response');
}
}

0 comments on commit 1b4aba3

Please sign in to comment.