canjs / can-stache-element

Create custom elements with can-stache and can-define-class
https://canjs.com/doc/can-stache-element.html
MIT License
3 stars 1 forks source link

StacheElement cannot be used as route.data #56

Closed phillipskevin closed 5 years ago

phillipskevin commented 5 years ago

This codepen shows the bug: https://codepen.io/kphillips86/pen/XLOBYb?editors=0011

If you change the URL, the count will be updated correctly, but if you click the +1 button, the route does not change.

This is because canReflect.serialize does not serialize StacheElements correctly.

phillipskevin commented 5 years ago

The first step to making this work is to change isBuiltIn:

https://github.com/canjs/can-reflect/blob/c59a2897251f7c34cb1b662795ed00f41a0a5d45/reflections/type/type.js#L191-L192

...so that it returns false for custom elements. This is because built-ins are always treated as already serialized:

https://github.com/canjs/can-reflect/blob/804c5ee6cbb86c00b40dbca5be44e1335ca6c7cd/reflections/shape/shape.js#L169-L171

justinbmeyer commented 5 years ago

Could we just check isObservableLike?

phillipskevin commented 5 years ago

Yeah, that would work I think. I'll try it when I get back to this.