-
Notifications
You must be signed in to change notification settings - Fork 2k
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
can't make bindings to objects on elements instantiated by mdv #81
Comments
Run your example and put a breakpoint in toolkit/src/register.js on base.bind (~line 101). Does this method get called for the repeated instances? I'm guessing it does, but then does not pass the 'inModel.isToolkitElement" test. Can you confirm? |
It doesn't get called for the repeated instances. |
Ok, in that case I suppose the problem is that the instances are not After they are stamped, look at the nodes, are they upgraded at all? I If so, if you don't mind, put a breakpoint in watchDOM in CustomElements.js On Mon, Apr 1, 2013 at 12:43 PM, Yvonne Yip notifications@github.comwrote:
|
The nodes are upgraded by watchDOM. Seems like the problem might be by the time watchDOM runs, the objects are already bound by mdv? |
Yes, that's the (first) problem. The nodes require upgrading before On Mon, Apr 1, 2013 at 12:52 PM, Yvonne Yip notifications@github.comwrote:
|
@rafaelw help? |
Sorry for the delay. I'm still thinking about this one. It's a tough problem and it's kind of tied in with the lifetime and upgrading of custom elements. In the abstract, I think there are two approaches to this:
2a) Call bind() on elements once they are insert into the document. The downside here is that it requires first removing the attributes which contain mustaches and worse it means that live DOM may attempt to act (fetch resources, run scripts, etc...) on an element which isn't really fully constructed. 2b) Expose imperative API on Node which allows the current bindings to be reflected. Template would call bind() while the element was in inert document, and when the custom element wakes up, it must inspect its bindings for any it wishes to override. I can't think of a concrete problem with this, other than it feels gross. Opinions very welcome. |
I'm confused about "1) Custom elements are upgraded while inside of template contents. When bind() gets called, the element is ready for it." Is the idea that whatever 'bind' does is cloned and bind is never called on copied instances? I don't have a good handle on what happens when cloning custom elements. A cloned custom instance must experience a fresh lifecycle, and I don't know what happens to the object state. |
I'm also curious about what happens to cloned custom elements. However, that I don't think that impacts this issue. Here are the steps for MDV creating an instance
Custom elements being upgraded while inside template contents helps because the elements would be ready to override bind() in step 2. |
Ok, thanks for that explanation.
I'm not sure this is true. For polyfill, we only need a hook where we can call our element upgrade code. If you supply that hook between steps 1 and 2, polyfill is happy and we can simulate your preferred modus operandi. Did I forget something? |
Fixed in toolkitchen/mdv@c22bcf7 |
reduction: issues/pending/mdv-repeat-binding
I cannot make an attribute binding to an object on an element instantiated by mdv, ie.,
The obj properties of x-foo are the stringified objects, not the actual object.
The text was updated successfully, but these errors were encountered: