Skip to content

CDN-provided gss.js doesn't parse when inlined #206

@du5t

Description

@du5t

I was testing bundling up a single-file HTML webapp with html-lnline, and found a couple spots where Chrome can't load gss.js if its contents are in <script> tags inline:

Engine.prototype.getWorkerURL = (function() {
    var scripts, src;
    if (typeof document !== "undefined" && document !== null) {
      scripts = document.getElementsByTagName('script');
      src = scripts[scripts.length - 1].src;
      if (!src.match(/gss/i)) {
        scripts = document.querySelectorAll('script[src*=gss]')[0];
        if (scripts && scripts.hasOwnProperty('length')) {              // MODIFIED HERE: threw error because scripts was undefined
          src = scripts[0].src;
        }
      }
    }
    return function(url) {
      if (typeof url !== 'string') {
        url = src;
      }
      if (!url) {throw new Error("Can not detect GSS source file");} // MODIFIED HERE: some ILLEGAL character was appearing
      return url;
    };
  })();

html-inline was otherwise faithful in inserting the script; fixing the above two lines in the bundled HTML file resulted in a working bundle.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions