Releases: canjs/can-stache-bindings
Clean up a variable defined twice
Removes a variable was defined twice in the code.
#556
Clean up after tests that throw errors
More error message improvements
- Make the “Unable to bind” error message more useful, instead of
Uncaught Error: can-event-queue: Unable to bind complete
:
var vm = new SimpleMap({
todo: {
complete: false
}
});
vm.handle = function() {} ;
var template = stache('<div on:complete:by:todo="handle()"></div>');
template(vm); // -> can-stache-bindings - Unable to bind "complete": "complete" is a property on a plain object "{"complete":false}". Binding is available with observable objects only. For more details check https://canjs.com/doc/can-stache-bindings.html#Callafunctionwhenaneventhappensonavalueinthescope_animation_'
- Explain that elements always set properties to Strings
can.preventDataBindings symbol support
This prevents adding bindings if a can.preventDataBindings
symbol on an element returns true
preventing events like on:click from creating viewmodels on normal elements
QUNIT2 upgrade
This updates the tests to use QUnit@2.x.x.
Warn users when binding to DOM event names on view models
The binding on:click="doSomething()"
on an element has two different meanings depending on context:
- if the element has a view model (e.g. is a can-component) listen for the view model to dispatch "click" then run
doSomething()
from the current scope context. - otherwise, listen for the element to dispatch "click"
The user may have meant to listen for DOM "click" events even if the element has a view model, but to do that, the user needs to write the binding as on:el:click="doSomething()"
. With this release, warnings are generated about this ambiguity: when an event is bound to the view model and the user didn't specify :vm:
, but the element has a listener for that event (i.e. a property named "on" + the event name), a warning is printed to the dev log.
Document using converters for simple setter
Adds how to use converters
param when using an expression that evaluates to a value to events docs:
on:click="this.complete = not(this.complete)"
Fixes #516
Handle two way binding with nested properties
Handle nested props with two way binding:
<script id="app-template" type="text/stache">
<home-page textData.textValue:bind="textString" />
<input value:bind="textString"/>
</script>
<script id="home-template" type="text/stache">
<h1>Home Page</h1>
<input value:bind="textData.textValue" />
</script>a
Resolves - canjs/can-stache#408
Allow late binding for on:EVENT:by:KEY
This patch release fixes a bug where the on:EVENT:by:KEY
binding syntax (e.g. on:click:by:scope.viewModel.clickyButton
) would error if the scope lookup key could not be found on the scope. The bug prevented the use of this syntax for cases where the object might get a value later, like for a component sharing a late-constructed event emitter to a sibling component, unless the binding was wrapped in an {{#if}}
block.
With this fix, on:EVENT:by:KEY
can be declared even when KEY
is not found in the scope. When KEY
is later set on the scope to an event emitter, the event is also bound as expected.
#510 for the problem description
#511 for the fix
https://jsbin.com/rehexuzufa/1/edit?html,js,output for an example usage