-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
Fixed a regression when standalone widgets wouldn't work
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
// polyfills | ||
require('./polyfills/function.prototype.bind.js'); | ||
require('./libs/pep'); | ||
|
||
var CMS = require('./modules/cms.base'); | ||
|
||
window.CMS = CMS; |
Large diffs are not rendered by default.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
var getDistPath = function (scriptFileName) { | ||
var fileNameReplaceRegExp = new RegExp(scriptFileName + '(\\?.*)?$', 'gi'); | ||
|
||
if (document.currentScript) { | ||
return document.currentScript.src.replace(fileNameReplaceRegExp, ''); | ||
} | ||
var scripts; | ||
var scriptUrl; | ||
var getSrc = function (listOfScripts, attr) { | ||
var fileName; | ||
var scriptPath; | ||
|
||
for (var i = 0; i < listOfScripts.length; i++) { | ||
scriptPath = null; | ||
if (listOfScripts[i].getAttribute.length !== undefined) { | ||
scriptPath = listOfScripts[i].getAttribute(attr, 2); | ||
} | ||
if (!scriptPath) { | ||
continue; // eslint-disable-line | ||
} | ||
fileName = scriptPath; | ||
fileName = fileName.split('?')[0].split('/').pop(); // get script filename | ||
if (fileName === scriptFileName) { | ||
return scriptPath; | ||
} | ||
} | ||
}; | ||
|
||
scripts = document.getElementsByTagName('script'); | ||
scriptUrl = getSrc(scripts, 'src'); | ||
if (scriptUrl) { | ||
return scriptUrl.replace(fileNameReplaceRegExp, ''); | ||
} | ||
return ''; | ||
}; | ||
|
||
module.exports = getDistPath; |