-
Notifications
You must be signed in to change notification settings - Fork 3.4k
$mdCompiler breaks if called multiple times with the same options object #2614
Comments
@rochdev - look forward to seeing your ideas/solution. |
Objects passed to a function should be considered immutable to avoid unexpected side-effects Closes angular#2614
@rochdev - In what scenario would the |
In my case it's an While I can (and did) just clone the options on every show, it is missing the point: modifying an object passed as parameter to a function is bad practice when it would be unexpected (if the purpose of the function is not explicitly mutation of the object). Also, it should be up to the caller whether or not the callee is called multiple times, not the callee (unless there is a compelling reason to prevent it). What do you think? |
@rochdev - Totally agree that the failure point (weakness) needs to be resolved. My earlier question was simply wondering why you were having scenarios with multiple calls. $mdCompiler should not maintain state, no force expectations on the caller to protect |
This is because
$mdCompiler
modifies the source object and gets confused if it receives the same object again later. Treating the options object as immutable would solve the issue at a very small performance cost (copying properties).I will try to submit a pull request this weekend.
The text was updated successfully, but these errors were encountered: