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

window.location.search is undefined #8

Closed
denar90 opened this issue Aug 22, 2018 · 2 comments
Closed

window.location.search is undefined #8

denar90 opened this issue Aug 22, 2018 · 2 comments
Assignees
Labels
API Something is missing or broken in the API surface

Comments

@denar90
Copy link

denar90 commented Aug 22, 2018

Since bundled script (via webpack 4) is loaded in worker, I suppose, window.location.search is undefined

Here is webpack added stuff and last line crashes

'use strict';

/* global __resourceQuery WorkerGlobalScope self */
/* eslint prefer-destructuring: off */

var url = require('url');
var stripAnsi = require('strip-ansi');
var log = require('loglevel').getLogger('webpack-dev-server');
var socket = require('./socket');
var overlay = require('./overlay');

function getCurrentScriptSource() {
  // `document.currentScript` is the most accurate way to find the current script,
  // but is not supported in all browsers.
  if (document.currentScript) {
    return document.currentScript.getAttribute('src');
  }
  // Fall back to getting all scripts in the document.
  var scriptElements = document.scripts || [];
  var currentScript = scriptElements[scriptElements.length - 1];
  if (currentScript) {
    return currentScript.getAttribute('src');
  }
  // Fail as there was no script to use.
  throw new Error('[WDS] Failed to get current script source.');
}

var urlParts = void 0;
var hotReload = true;
if (typeof window !== 'undefined') {
  var qs = window.location.search.toLowerCase();
@kristoferbaxter kristoferbaxter self-assigned this Aug 23, 2018
@kristoferbaxter kristoferbaxter added the API Something is missing or broken in the API surface label Aug 23, 2018
@dreamofabear
Copy link
Collaborator

window.location.search is no longer undefined but it returns WorkerLocation.search which is not the expected value. We'll need to hydrate this from the main thread for read access. Writing is another matter.

@samouri
Copy link
Member

samouri commented Jul 12, 2021

Deduping with #1068

@samouri samouri closed this as completed Jul 12, 2021
@renovate renovate bot mentioned this issue Jul 5, 2023
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Something is missing or broken in the API surface
Projects
None yet
Development

No branches or pull requests

4 participants