canjs / can-component

Custom elements and widgets
https://canjs.com/doc/can-component.html
MIT License
8 stars 8 forks source link

Make component late binding work with the `scope` if there was one. #290

Open justinbmeyer opened 6 years ago

justinbmeyer commented 6 years ago

This is very likely a problem that should be fixed in both stache and can-view-callbacks. But in a training, someone was progressively loading a component that was already written to the page.

This would throw an error about the scope in scope.computeData() not being defined.

This warning isn't helpful. But I also think we should support it. Ideally, when stache finds a custom element, it can register a listener of sorts for if that element becomes defined:

viewCallbacks.onTag("todo-list", function(el, scopeData){
 ....
})

This way, if the component becomes defined, it can instantiate itself with stache's scope.