Skip to content
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

Merged
merged 27 commits into from
Aug 9, 2017
Merged

Colon bindings #260

merged 27 commits into from
Aug 9, 2017

Conversation

justinbmeyer
Copy link
Contributor

@justinbmeyer justinbmeyer commented Jul 7, 2017

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()"/>

@phillipskevin phillipskevin changed the title Not Ready: Colon bindings Colon bindings Aug 3, 2017
@phillipskevin
Copy link
Contributor

@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).

var viewModel,
getViewModel = function() {
return viewModel || (viewModel = canViewModel(el));
},
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this needed?

Copy link
Contributor

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.

if(attributeName.indexOf('can-') === 0) {
event = attributeName.substr("can-".length);
bindingContext = el;
} else if(attributeName.indexOf("on:") === 0 ) {
Copy link
Contributor Author

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",
Copy link
Contributor Author

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)

Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants