Permalink
Browse files

rewritten remoteAttribute, removing mutate events

  • Loading branch information...
1 parent 61111fa commit ef281db9749ac751e9ad74e1df66e45c133aa48c @hay committed Aug 15, 2012
Showing with 27 additions and 13 deletions.
  1. +2 −13 stapes.js
  2. +25 −0 test/test.js
View
15 stapes.js
@@ -334,8 +334,8 @@
removeAttribute : function(key) {
// Check that the item exists before emitting events
- var itemExists = this.has(key),
- oldValue = _.attr(this._guid)[key];
+ var itemExists = this.has(key);
+ var oldValue = _.attr(this._guid)[key];
if (!itemExists) {
return;
@@ -351,17 +351,6 @@
// key here!
this.emit('change:' + key);
- // Throw namespaced and non-namespaced 'mutate' events as well with
- // the old value data as well and some extra metadata such as the key
- var mutateData = {
- "key" : key,
- "newValue" : null,
- "oldValue" : oldValue || null
- };
-
- this.emit('mutate', mutateData);
- this.emit('mutate:' + key, mutateData);
-
// Throw remove event and namespaced remove event.
this.emit('remove', key);
this.emit('remove:' + key);
View
25 test/test.js
@@ -79,6 +79,31 @@ test("update", function() {
});
});
+module("remove");
+
+test("remove", function() {
+ var module = Stapes.create();
+ module.set('foo', 'bar');
+
+ module.on({
+ 'change': function( key ){
+ ok(key === 'foo', 'change event with key of attribute');
+ },
+
+ 'change:foo': function(key, e){
+ ok(e.type === 'change:foo', 'change:key event');
+ },
+ 'remove': function( key ){
+ ok(key === 'foo', 'remove event with key of attribute');
+ },
+ 'remove:foo': function(key, e){
+ ok(e.type === 'remove:foo', 'change:key event');
+ }
+ });
+
+ module.remove('foo');
+})
+
module("iterators");
test("each with a single object", function() {

0 comments on commit ef281db

Please sign in to comment.