1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-18 17:23:37 +00:00

remove inline fallback code for CSP

This commit is contained in:
Kyle Spearrin
2017-06-17 10:08:47 -04:00
parent 00007c20a7
commit ce1352cb9f
4 changed files with 49 additions and 12 deletions

View File

@@ -0,0 +1,9 @@
function loadScriptIfMissing(condition, path) {
if (!condition) {
document.write('<script src="' + path + '?v=' + cacheTag + '"><\/script>');
}
}
loadScriptIfMissing(window.jQuery, 'lib\/jquery\/jquery.min.js');
loadScriptIfMissing(window.jQuery && window.jQuery.fn && window.jQuery.fn.modal, 'lib\/bootstrap\/js\/bootstrap.min.js');
loadScriptIfMissing(window.angular, 'lib\/angular\/angular.min.js');

17
src/js/fallback-styles.js Normal file
View File

@@ -0,0 +1,17 @@
var cacheTag = '/* @echo cacheTag */' || '';
function loadStylesheetIfMissing(property, value, paths) {
var scripts = document.getElementsByTagName('SCRIPT'),
siblings = scripts[scripts.length - 1].previousElementSibling,
meta = document.defaultView && document.defaultView.getComputedStyle ?
document.defaultView.getComputedStyle(siblings) : siblings.currentStyle;
if (meta && meta[property] !== value) {
for (var i = 0; i < paths.length; i++) {
document.write('<link rel="stylesheet" href="' + paths[i] + '?v=' + cacheTag + '" />');
}
}
}
loadStylesheetIfMissing('visibility', 'hidden', ['lib\/bootstrap\/css\/bootstrap.min.css']);
loadStylesheetIfMissing('fontFamily', 'FontAwesome', ['lib\/font-awesome\/css\/font-awesome.min.css']);