-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Colon bindings #260
Colon bindings #260
Conversation
@justinbmeyer this is ready for review if you can take a look. (can't add you as a reviewer since you opened the PR initially). |
can-stache-bindings.js
Outdated
var viewModel, | ||
getViewModel = function() { | ||
return viewModel || (viewModel = canViewModel(el)); | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because otherwise a viewModel will always be set up on the element and we will always use vm
binding instead of element binding.
can-stache-bindings.js
Outdated
if(attributeName.indexOf('can-') === 0) { | ||
event = attributeName.substr("can-".length); | ||
bindingContext = el; | ||
} else if(attributeName.indexOf("on:") === 0 ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there wouldn't be much benefit, but we might want to cache ":on"
in the outer scope so we can do:
.indexOf(onMatchStr)
and onMatchStr.length
@@ -31,28 +31,29 @@ | |||
"main": "can-stache-bindings" | |||
}, | |||
"dependencies": { | |||
"can-attribute-encoder": "^0.3.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should hard-code core deps that are not >1.0
(we don't do this everywhere (can-stache-key), but we should)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I released this as > 0.1.0
so that we could publish patches for docs and things.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what do you mean? It should be hard-coded because the API might change. Everything included by core shouldn't break if it gets updated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the API changes, we should publish 0.4.0
. In that case, it wouldn't get updated here.
Not hard-coding it allows us to publish bug fixes and doc updates.
For #229
- Bring back other tests.
- Tests for
<div on:born:by:person="animate('slowly')"/>
- Make it able to bind directly to the element if there is no view model.
- Write tests for
getBindingInfo
.- What should the behavior now be of
on:someEvent
on:some-event
.- What is the behavior of
{fooBar}
,{foo-bar}
,(someEvent)
,(some-event)
.- How should we best encode / decode to the DOM.
- In can-view-parser if someone has
(foo bar)="zed"
->(foo\\sbar)
-
on:someEvent
->on:some\\cevent
- Why in can-view-parser: Because we allow
<div {{#if foo}}on:someEvent="doSomething()"{{/if}}>
- Other binding specifiers:
-
<input on:enter:value:to="scopeValue"/>
- Specify winner in initialization or stickiness with
<location-feed location:bind="userLocation">
- stickiness with something like
<input value:bind="age"/>
- Set prop -
<input prop:value:bind="age"/>
- Custom events and props:
<can-import viewModel:to="drag" from="can-dom/drag/event"/> <div on:[drag]="doSomething()"/>