knockout.localStorage icon indicating copy to clipboard operation
knockout.localStorage copied to clipboard

Fails when no first augment is passed into the ko.observable when ko normal assigns a default value

Open sudo-ben opened this issue 14 years ago • 1 comments

sudo-ben avatar Apr 13 '12 08:04 sudo-ben

I haven't done a Pull request, but you can fix the problem by beginning the constructor like this (only tested in the latest FireFox version):

ko[method] = function(initialValue, options) {
    // see if the initialValue is in fact the options argument, swap their values
    if (options == undefined && initialValue != undefined && initialValue.hasOwnProperty('persist')) {
        options = initialValue;
        initialValue = null;
    }

    options = options || {};
    ...

lavandowska avatar Jul 23 '13 19:07 lavandowska