'use strict'

module.exports = {
  elementIsEmpty: elementIsEmpty
}

/**
 * Tells if an element is empty (pure JS)
 * i.e. if:
 * - it contains nothing,
 * - or it contains an empty element,
 * - or the only contained element is the mceBogus element
 * @method
 * @static
 * @param {Node} node The node to check if it is empty
 * @param {window} [contextWindow] The contextual window for this element
 * @returns {Boolean} true if the element is concidered empty.
 */
function elementIsEmpty (element, contextWindow) {
  if (!contextWindow) {
    contextWindow = window
  }
  if (!element || !(element instanceof contextWindow.HTMLElement)) {
    throw new TypeError('argument 1 must be an instance of Node.')
  }
  return !element.textContent.trim()
}

@@ -280,18 +280,28 @@
 am %7B
-Node%7D node
+HTMLElement%7D element
  The
@@ -306,16 +306,24 @@
 he node 
+element 
 to check
@@ -460,17 +460,17 @@
 t is con
-c
+s
 idered e
@@ -553,20 +553,16 @@
 indow) %7B
-%0A   
  context
@@ -576,18 +576,16 @@
 = window
-%0A 
  %7D%0A  if 
@@ -586,24 +586,25 @@
 %0A  if (!
+(
 element 
 %7C%7C !(ele
@@ -599,13 +599,41 @@
 ent 
+instanceof window.HTMLElement 
 %7C%7C 
-!(
 elem
@@ -677,16 +677,98 @@
 ent)) %7B%0A
+    console.error('TypeError element: ', element, 'contextWindow', contextWindow)%0A
     thro
@@ -822,12 +822,19 @@
  of 
-Node
+HTMLElement
 .')%0A

fix domUtils.elementIsEmpty()