riganti / dotvvm

Open source MVVM framework for Web Apps
https://www.dotvvm.com
Apache License 2.0
743 stars 97 forks source link

Dictionary item retrieval binding throws although item exists. #1781

Closed MichalTichy closed 6 months ago

MichalTichy commented 7 months ago

Hi,

During postback we are filling collection and in the same request additional metadata are stored for all items inside dictionary.

Unfortunately the binding that retrieves metadata from dictionary fails during render of new items. image_6aace769.png

-image_7152a048.png

With following fix everything works fine. image_a6d294ab.png

tomasherceg commented 7 months ago

I guess it is caused because the binding accessing the Dictionary is evaluated before the items get in the collection.

I think all JS methods on Dictionary should not throw any exceptions and should do null propagation instead.

exyi commented 7 months ago

Agreed, we should avoid throwing exception in most client-side translations. We can then use the same translation for LINQ First and FirstOrDefault, and similar cases