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

[0.8-preview] All properties are available for data binding #1262

Closed
arthurevans opened this issue Mar 6, 2015 · 1 comment
Closed

[0.8-preview] All properties are available for data binding #1262

arthurevans opened this issue Mar 6, 2015 · 1 comment
Labels

Comments

@arthurevans
Copy link

Not sure if this is intentional or not, so I'm filing it as an issue.

In 0.5, only properties explicitly exposed via attributes or publish were available for data binding from the outside (that is, binding to property1 using an attribute like property1="{{someThing}}").

0.5, can't bind to an unpublished property:
http://jsbin.com/tumaxi/3/edit

In 0.8, you appear to be able to bind to any property, whether or not it's in the properties object:
http://jsbin.com/muvozu/2/edit

Is this a bug or a feature? I could go either way, so seeking clarification.

@arthurevans arthurevans added the 0.8 label Mar 6, 2015
@kevinpschaaf
Copy link
Member

This is as designed. It results from a fundamental difference between how data binding worked in 0.5 vs. 0.8.

In 0.5, the TemplateBinding lib used Node.bind which is called by the source of the binding on the target of the binding at instance time and gives it an Observable object. When the value of the property in the source changes, the node at the target of the binding is notified via the Observable and allowed to do what it will with the new value bound to the given name.

In 0.8, binding associations are recorded in the source element of the binding at declaration time. When the value of the property in the source changes, it simply sets the property of the given name on the target element. So control is inverted such that the source pokes the value into the target, rather than the target being notified by the source and poking itself (or skipping any property assignment altogether, as in unpublished 0.5 properties).

The 0.8 implementation is a great simplifying factor in that there is no instance-time cost (binding side-effects are baked into the element prototype once at declaration time) and avoids any heavy machinery for notification; a limitation is that the target of the binding has no ability to "reject" the assignment, other than to declare a property read-only.

There are possible ways to avoid binding to non-public values at declaration time with added cost/complexity. This could be added to a "debug mode" or "strict mode" in the future.

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

No branches or pull requests

2 participants