Skip to content
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

deferUpdates, 'with' binding, and a validation extender #594

Open
petemill opened this issue Nov 25, 2015 · 1 comment
Open

deferUpdates, 'with' binding, and a validation extender #594

petemill opened this issue Nov 25, 2015 · 1 comment
Labels

Comments

@petemill
Copy link

When using the latest version of knockout, v3.4 with knockout-validation v2.0.3, I get some crashes due to infinite recursion. I have narrowed it down to the following case, where a with: binding instantiates a new VM object containing an observable with a validation extender. The problem does not happen when the validation extender is removed.

HTML:

<div data-bind="with: EditableRepVM($data)">
  <p data-bind="text: Name"></p>
</div>

JS:

ko.options.deferUpdates = true;
class ViewModel {
  constructor(){

  }


  EditableRepVM(nonEditableData) {

    console.debug('EditableRepVM called');
    var newItem = {
    };
    newItem.Name = ko.observable('default name').extend({required: true});
    return newItem;
  }
}
ko.applyBindings(new ViewModel());

With the above, console output is:

EditableRepVM called
EditableRepVM called
EditableRepVM called
...
Uncaught Error: 'Too much recursion' after processing 5000 task groups.
@ processTasks  @   knockout-debug.js:1081

When removing the validation extender, 'EditableRepVM called' is only logged once, as expected and the page does not crash.

Here is a codepen demonstrating this case. Remove the commented code to experience the issue:
http://codepen.io/petemill/pen/GpaPOO?editors=101

@mbest
Copy link

mbest commented Nov 25, 2015

See knockout/knockout#1934

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

No branches or pull requests

3 participants