Quantcast
Viewing all articles
Browse latest Browse all 3491

How to use can.view.attr-based components in a production build?

I'm trying to use some components that are based on can.view.attr() but I can't get them to work in a StealJS production build, even though they work in development mode. The attrHandler callback doesn't get called when a rendered template makes use of the attribute.

The root issue seems to be that the can.view.attr() definition must be executed before the template is parsed, and that the template is parsed at different points for a dev vs. production build. 

To ensure the component is loaded before parsing, I have to use stealconfig.js to inject the component dependency on either the template or the template loader. This works for development mode but not once built - variations of this approach lead to triggering "window is not defined" errors during the build, or the callback isn't called once viewing in production.

I just wanted to check here first to see if I was missing something simple. This is for CanJS 2.1.3 with new StealJS.


Viewing all articles
Browse latest Browse all 3491

Trending Articles