can.sub should return null if value is undefined or null #429
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently can.sub only returns null if the property it is trying to replace is
undefined
. It should do the same if the value is null.This bug rears its ugly head in can.Control when templated event handlers get parsed.
Say you have a compute named
val1
in your defaults which isnull
and you have a templated event that looks like'{val1} change
. When can.sub is run on that string and the options you get' change'
which will setup a binding on the Control's element for any change event from the DOM (from form elements).So in this case, you get this very weird behavior of having the handler for a compute change run when form elements are updated.
Example fiddle: http://jsfiddle.net/jCjBw/1/