Incorrect handling of properties with periods (e.g. "foo.bar")
knockout.mapping's internal design assumes that properties will not have periods, but this is never mentioned in the documentation.
I made a JSFiddle demonstrating the problem: http://jsfiddle.net/cspotcode/JtkGC/6/
In the fiddle, plainJS["a.b"] is treated the same way as plainJS["a"]["b"] (it's ignored)
I'm not sure what the proper solution should be.
I don't think this behavior can be changed without breaking backwards compatibility. In your case for instance, there is no way for the plugin to figure out if you wanted to ignore ["a.b"] or ["a"]["b"]. I'm also not sure how to best solve this (while maintaining compatibility).
Current behavior hides both ["a.b"] and ["a"]["b"]. However, I'm guessing most people think that correct behavior is to hide only ["a"]["b"]. Thus hiding ["a.b"] is a bug which can be fixed without breaking backwards compatibility.
If that's the case, we can change current behavior to escape periods within property names. So if I wanted to hide ["a.b"] I'd have to do:
var mappingOptions = { ignore: ["a\\.b"] };
This allows crazy people with periods in their property names to construct non-ambiguous mapping options, and it doesn't break compatibility for everyone else.
The escape characters are certainly a fair suggestion. I wouldn't suggest that people using that syntax are crazy per se, though. :)
Would you like to take a stab at fixing it? The code you should be looking at is probably the fullPropertyName-related code.
I'd be delighted (time permitting) I'll try to throw something together tonight.
Agreed on not calling people crazy, especially since I submitted this bug report :D
:) Okay, good! If you have any questions, just add them to this issue. It might be a good idea to just take your fiddle-code and use that as a failing integration test to start with, and build from there.
Just a heads-up, I'm still keen on fixing this problem but first I have to get Knockout added to my employer's "we don't own your inventions on these projects" list. ("Intellectual Property Disclosure Form"? I forget what it's called...)
Okay, that certainly seems like something you'd want to have filled out!
@cspotcode have you made any progress on filling out that form? :)
Yeah, sorry for the extended radio silence. I talked to my boss and verified that this kind of contribution (bugfixing) is allowed.
I'll try to carve out some time later this week to work on a fix.
@cspotcode No worries, just checking if you were still with us :)