source: trip-planner-front/node_modules/webpack-dev-server/client/utils/getCurrentScriptSource.js@ 1ad8e64

Last change on this file since 1ad8e64 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 658 bytes
Line 
1'use strict';
2
3function getCurrentScriptSource() {
4 // `document.currentScript` is the most accurate way to find the current script,
5 // but is not supported in all browsers.
6 if (document.currentScript) {
7 return document.currentScript.getAttribute('src');
8 } // Fall back to getting all scripts in the document.
9
10
11 var scriptElements = document.scripts || [];
12 var currentScript = scriptElements[scriptElements.length - 1];
13
14 if (currentScript) {
15 return currentScript.getAttribute('src');
16 } // Fail as there was no script to use.
17
18
19 throw new Error('[WDS] Failed to get current script source.');
20}
21
22module.exports = getCurrentScriptSource;
Note: See TracBrowser for help on using the repository browser.