summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/flash.js
diff options
context:
space:
mode:
authorPhil Hughes <me@iamphill.com>2017-10-03 15:01:02 +0100
committerPhil Hughes <me@iamphill.com>2017-10-10 10:14:22 +0100
commitd668294f28c7a54a34b6cc896953ece1c9def15d (patch)
tree0bdda11b9a5dc63bc81cf3fb333866a87845a6a1 /app/assets/javascripts/flash.js
parentfa2af5e0f5e290eff32f62c7ea9f935a6ad33967 (diff)
downloadgitlab-ce-d668294f28c7a54a34b6cc896953ece1c9def15d.tar.gz
spec fixes
Diffstat (limited to 'app/assets/javascripts/flash.js')
-rw-r--r--app/assets/javascripts/flash.js15
1 files changed, 10 insertions, 5 deletions
diff --git a/app/assets/javascripts/flash.js b/app/assets/javascripts/flash.js
index 69e4f884f34..1a52c5a07bf 100644
--- a/app/assets/javascripts/flash.js
+++ b/app/assets/javascripts/flash.js
@@ -1,8 +1,10 @@
import _ from 'underscore';
const hideFlash = (flashEl) => {
- flashEl.style.transition = 'opacity .3s'; // eslint-disable-line no-param-reassign
- flashEl.style.opacity = '0'; // eslint-disable-line no-param-reassign
+ Object.assign(flashEl.style, {
+ transition: 'opacity .3s',
+ opacity: '0',
+ });
flashEl.addEventListener('transitionend', () => {
flashEl.remove();
@@ -33,8 +35,11 @@ const createFlashEl = (message, type) => `
</div>
`;
-const Flash = function Flash(message, type = 'alert', parent = document, actionConfig = null) {
+const createFlash = function createFlash(message, type = 'alert', parent = document, actionConfig = null) {
const flashContainer = parent.querySelector('.flash-container');
+
+ if (!flashContainer) return null;
+
flashContainer.innerHTML = createFlashEl(message, type);
const flashEl = flashContainer.querySelector(`.flash-${type}`);
@@ -61,8 +66,8 @@ const Flash = function Flash(message, type = 'alert', parent = document, actionC
};
export {
- Flash as default,
+ createFlash as default,
createFlashEl,
hideFlash,
};
-window.Flash = Flash;
+window.Flash = createFlash;