Lombiq/Helpful-Extensions

Fix issues in target-blank.js (OSOE-576)

0liver opened this issue · 4 comments

0liver commented

Follow-up to #104.

See comments here and below.

  1. Use DOMContentLoaded event instead of load. There's no third parameter there.
  2. Remove the setTimeout indirection from the event handler. Simply pass targetBlank as the handler.
  3. Remove superfluous configuration from package.json file:
    a. "nodejsExtensions"
    b. "devDependencies"
  4. Use compiled scripts from wwwroot\js folder instead of wwwroot\scripts here after 3.a.
  5. Reorder the conditions here.

Jira issue

From target-blank.js the whole second part can be removed starting with "window.addEventListener...", that makes the "Use DOMContentLoaded event instead of..." part unneccesary, right?

0liver commented

No.

    window.addEventListener(
        'load',
        () => {
            window.setTimeout(targetBlank, 100);
        },
        false);

Should become:

    document.addEventListener('DOMContentLoaded', targetBlank);

I see, understood.

Fixed in #117.