Comparing version 4.0.0-pre.5 to 4.0.0-pre.6
@@ -541,1 +541,10 @@ /* jshint asi:true */ | ||
}); | ||
QUnit.test("can.isBound", function(){ | ||
var Person = Map.extend({ | ||
first: "any", | ||
last: "any" | ||
}); | ||
var p = new Person(); | ||
QUnit.ok(! p[canSymbol.for("can.isBound")](), "not bound"); | ||
}); |
@@ -525,57 +525,4 @@ /* jshint -W079 */ | ||
// ### _bindsetup and _bindteardown | ||
// Placeholders for bind setup and teardown. | ||
//_eventSetup: function(){}, | ||
//_eventTeardown: function(){}, | ||
// ### one | ||
// Listens once to an event. | ||
one: canEvent.one, | ||
// ### bind | ||
// Listens to an event on a map. | ||
// If the event is a computed property, | ||
// listen to the compute and forward its events | ||
// to this map. | ||
addEventListener: function (eventName, handler) { | ||
var computedBinding = this._computedAttrs && this._computedAttrs[eventName]; | ||
if (computedBinding && computedBinding.compute) { | ||
if (!computedBinding.count) { | ||
computedBinding.count = 1; | ||
canReflect.onValue(computedBinding.compute, computedBinding.handler, "notify"); | ||
} else { | ||
computedBinding.count++; | ||
} | ||
} | ||
// Sets up bubbling if needed. | ||
bubble.bind(this, eventName); | ||
return canEvent.addEventListener.apply(this, arguments); | ||
}, | ||
// ### unbind | ||
// Stops listening to an event. | ||
// If this is the last listener of a computed property, | ||
// stop forwarding events of the computed property to this map. | ||
removeEventListener: function (eventName, handler) { | ||
var computedBinding = this._computedAttrs && this._computedAttrs[eventName]; | ||
if (computedBinding) { | ||
if (computedBinding.count === 1) { | ||
computedBinding.count = 0; | ||
canReflect.offValue(computedBinding.compute, computedBinding.handler); | ||
} else { | ||
computedBinding.count--; | ||
} | ||
} | ||
// Teardown bubbling if needed. | ||
bubble.unbind(this, eventName); | ||
return canEvent.removeEventListener.apply(this, arguments); | ||
}, | ||
// ### compute | ||
@@ -632,4 +579,50 @@ // Creates a compute that represents a value on this map. If the property is a function | ||
// makes it so things can read this. | ||
canEvent(Map.prototype); | ||
// ### bind | ||
// Listens to an event on a map. | ||
// If the event is a computed property, | ||
// listen to the compute and forward its events | ||
// to this map. | ||
Map.prototype.addEventListener = function (eventName, handler) { | ||
var computedBinding = this._computedAttrs && this._computedAttrs[eventName]; | ||
if (computedBinding && computedBinding.compute) { | ||
if (!computedBinding.count) { | ||
computedBinding.count = 1; | ||
canReflect.onValue(computedBinding.compute, computedBinding.handler, "notify"); | ||
} else { | ||
computedBinding.count++; | ||
} | ||
} | ||
// Sets up bubbling if needed. | ||
bubble.bind(this, eventName); | ||
return canEvent.addEventListener.apply(this, arguments); | ||
}; | ||
// ### unbind | ||
// Stops listening to an event. | ||
// If this is the last listener of a computed property, | ||
// stop forwarding events of the computed property to this map. | ||
Map.prototype.removeEventListener = function (eventName, handler) { | ||
var computedBinding = this._computedAttrs && this._computedAttrs[eventName]; | ||
if (computedBinding) { | ||
if (computedBinding.count === 1) { | ||
computedBinding.count = 0; | ||
canReflect.offValue(computedBinding.compute, computedBinding.handler); | ||
} else { | ||
computedBinding.count--; | ||
} | ||
} | ||
// Teardown bubbling if needed. | ||
bubble.unbind(this, eventName); | ||
return canEvent.removeEventListener.apply(this, arguments); | ||
}; | ||
// ### etc | ||
@@ -636,0 +629,0 @@ // Setup on/off aliases |
{ | ||
"name": "can-map", | ||
"version": "4.0.0-pre.5", | ||
"version": "4.0.0-pre.6", | ||
"description": "Observable Objects", | ||
@@ -5,0 +5,0 @@ "homepage": "http://canjs.com", |
1528
79489