Reading through the knockout.js source code I come accross this line
disposeWhenOption = options["disposeWhen"] || options.disposeWhen
I've never seen this before and everything I know about javascript says there is no case when the two sides of the ||
would be different. Why might have the knockout team used this construct?
This comes as a result of symbol mangling performed by the Closure Compiler. From the Closure Compiler docs:
Closure Compiler compilation never changes string literals in your code, no matter what compilation level you use. This means that compilation with ADVANCED_OPTIMIZATIONS treats properties differently depending on whether your code accesses them with a string. If you mix string references to a property with dot-syntax references, Closure Compiler renames some of the references to that property but not others. As a result, your code will probably not run correctly.
Using both the dot syntax and the string literal is the "safe" way to work around this, as it helps ensure a client using an unexported part of the API but not using the closure compiler on their own code will not have any problems.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With