/**
# Show and Hide
*/
/* global module */
'use strict';

const {findWithin} = require('./b8r.dom.js');
const {dispatch} = require('./b8r.events.js');

const show = element => {
  if (element.style.display === 'none') {
    element.style.display = element.getAttribute('data-orig-display') || '';
    findWithin(element, '[data-event*="show"]')
        .forEach(elt => dispatch('show', elt));
  }
};

const hide = element => {
  if (element.getAttribute('data-orig-display') === null &&
      (element.style.display && element.style.display !== 'none')) {
    element.setAttribute('data-orig-display', element.style.display);
    findWithin(element, '[data-event*="hide"]')
        .forEach(elt => dispatch('hide', elt));
  }
  element.style.display = 'none';
};

module.exports = {
  show,
  hide
};

@@ -32,16 +32,25 @@
 l module
+, require
  */%0A'use
@@ -113,24 +113,23 @@
 %0Aconst %7B
-dispatch
+trigger
 %7D = requ
@@ -166,23 +166,34 @@
  show = 
+(
 element
+, ...args)
  =%3E %7B%0A  
@@ -355,16 +355,22 @@
 %22show%22%5D'
+, true
 )%0A      
@@ -387,24 +387,23 @@
 (elt =%3E 
-dispatch
+trigger
 ('show',
@@ -402,24 +402,33 @@
 ('show', elt
+, ...args
 ));%0A  %7D%0A%7D;%0A%0A
@@ -440,23 +440,34 @@
  hide = 
+(
 element
+, ...args)
  =%3E %7B%0A  
@@ -709,16 +709,22 @@
 %22hide%22%5D'
+, true
 )%0A      
@@ -745,16 +745,15 @@
  =%3E 
-dispatch
+trigger
 ('hi
@@ -760,16 +760,25 @@
 de', elt
+, ...args
 ));%0A  %7D%0A

fix — show needs to send event to the original element (include_self) fix — show needs to call trigger, not dispatch, since show/hide are non-standard events