SteveSanderson/knockout.mapping — Issue #34: Root-level mapping issue
Author: matb33
Created: 2011-10-18 02:25:11+00:00
State: open

I've run into an issue where when calling ko.mapping.fromJS a second time around, my browser crashes. I haven't had time to understand enough of what's going on but managed to get it working with this change at line 173

// Is there only a root-level mapping present?
if ((options.create instanceof Function) || (options.update instanceof Function) || (options.key instanceof Function) || (options.arrayChanged instanceof Function)) {
if (!options.hasOwnProperty("")) {
options = {
"": options
};
}
}

Notice the !options.hasOwnProperty(""). On the second call to fromJS, I'd get an infinitely recursing options with an empty property name, which was causing the crash.

I'm not sure if this was the correct fix, but I'm passing it along in case it does make sense to you.