canjs / can-view-import

Import dependencies in CanJS views
https://canjs.com/doc/can-view-import.html
MIT License
3 stars 2 forks source link

Add a warning - error when using bindings on import instead of the element itselt #82

Open nriesco opened 6 years ago

nriesco commented 6 years ago

It is not the first time, it has happened to me every once in a while, I feel dumb about it but it would be great to have a warning when setting bindings on <can-import> tags such as:

<can-import from="~/apps/orders/seller-drafts/index" myVar:bind="selectedValue" />

I just couldn't figure out what was wrong for a while and I guess a warning could be easily generated, especially considering the amount of current warnings similar to those when using attributes on almost every element.

Thanks

frank-dspeed commented 6 years ago

@nriesco can you be more specific ? i don't understand what kind of warning you want here exactly on what exact condition.

nriesco commented 6 years ago

that code is wrong:

<can-import from="~/apps/orders/seller-drafts/index" myVar:bind="selectedValue" />

you should use something like this:

<can-import from="~/apps/orders/seller-drafts/index" />
<seller-drafts myVar:bind="selectedValue" />

But it is hard to see by a human. It would be great that a warning/error was triggered when writing code like this.

frank-dspeed commented 6 years ago

@nriesco your right setting var on import is not possible only on instancing via the tag