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

runUpdate / onUpdate callback has wrong scope on initial load #77

Closed
marcysutton opened this issue Jul 10, 2018 · 1 comment
Closed

Comments

@marcysutton
Copy link
Contributor

marcysutton commented Jul 10, 2018

In an older version of CodeFlask, onUpdate would run on the initial update to the textarea. It's still making the call to runUpdate, but the initial function scope is wrong so the callback never runs on page load.

If you log this in runUpdate on page load it points to window...where Codeflask won't find this.updateCallBack later on. Once you type in the textarea, the scope is set to the appropriate object.

This is the part of the code that is wrong: https://github.com/kazzkiq/CodeFlask/blob/master/src/codeflask.js#L295

Fix: Change onUpdate to bind the correct scope

updateCode(newCode) {
    // previous code here
    setTimeout(this.runUpdate.bind(this), 1);
}
@kazzkiq
Copy link
Owner

kazzkiq commented Jul 16, 2018

Damn, what a bundler. Thanks for the highlight, its now fixed in v1.1.1.

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

No branches or pull requests

2 participants