Skip to content

String values in mapping cause infinite recursion in extendObject #107

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
lawnsea opened this issue Sep 10, 2012 · 0 comments · Fixed by #108
Closed

String values in mapping cause infinite recursion in extendObject #107

lawnsea opened this issue Sep 10, 2012 · 0 comments · Fixed by #108

Comments

@lawnsea
Copy link
Contributor

lawnsea commented Sep 10, 2012

Repro:
Run the following in the console of the unit tests:

    var model = ko.mapping.fromJS({ foo: 'bar' }, {
        fiz: 'applesauce'
    });

    ko.mapping.fromJS({ foo: 'baz' }, model);

Expected:
Model.foo -> 'baz'

Observed:
extendObject recurses infinitely on 'a' (because 'a'[0] == 'a').

We ran into this after wrapping fromJS to support other mapping options, some of which have string values. I realize that there are no mapping options for which a string is a legal value in vanilla knockout, but this is a particularly gnarly way to crash, as you lose the stack trace and debuggers don't break on the error.

We have to fix this for our project, so expect a pull request shortly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants