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

initEditor is overriding globally scoped name #68

Closed
davidnewcomb opened this issue Jun 8, 2018 · 0 comments
Closed

initEditor is overriding globally scoped name #68

davidnewcomb opened this issue Jun 8, 2018 · 0 comments

Comments

@davidnewcomb
Copy link

From kv-markdown.js:

function initEditor(params) {
    var input = params.source,
        editor = params.editor,
        preview = params.preview,
        target = params.target,
        maximize = params.maximize,
        container = params.container,
        modal = editor.slice(1) + '-modal',
        export1 = params.export1,
        export2 = params.export2,
        defHeight = params.height,
        $iframe = $('#' + params.iframeId),
        $form = $iframe.contents().find('form'),
        fullscreen = input.slice(1) + '-fullscreen';
    filename = params.filename;  //// <--------

    $(input).focus(function () {
        $(editor).addClass('active');
    });

filename is not defined inside your file, and the area where it is used is in the global space. So by setting this variable here you are potentially overwriting someone else' variable. It is difficult to say what the effect is. It could be nothing or everything!

I think you want:

        $form = $iframe.contents().find('form'),
        fullscreen = input.slice(1) + '-fullscreen',  /// <---
        filename = params.filename;  //// <--------

    $(input).focus(function () {
        $(editor).addClass('active');
    });
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

1 participant