documentcloud/backbone — pull request #2646 by gkostov (2013-07-02 11:04:29+00:00)
Title: a "force" option for Model.set()

As it was mentioned in #944 it happens so that a value is set on a model but it will not trigger `change` events if the new value is found to be identical with the stored one. Even though I agree that these events need not be fired if the value hasn't actually changed, I still think that it should be fired if the caller requests so. It was suggested to manually trigger `change` but if I'm not making some trivial mistake then the outome of that manual trigger is definitely not the same as the original `set()` call where the model reference that the caller will receive provides the "changed" hash for example.
The `force` option suppresses the simple equality check of the new value and proceeds as if it is actually different and triggers all related events.
In my actual case I have a model for which some of the attributes are also models and I believe it is expected that when an attribute changes the events on the containing model should fire. I plan to further develop a model which will be able to natively accept models as attributes and will relay `change` events from them. But with this patch and some additional code I can go on for now.