amdclean icon indicating copy to clipboard operation
amdclean copied to clipboard

Compiling React.js source results in an error

Open alahtarin opened this issue 10 years ago • 0 comments

React.js has a following function:

function hasArrayNature(obj) {
  return (
    // not null/false
    !!obj &&
    // arrays are objects, NodeLists are functions in Safari
    (typeof obj == 'object' || typeof obj == 'function') &&
    // quacks like an array
    ('length' in obj) &&
    // not window
    !('setInterval' in obj) &&
    // no DOM node should be considered an array-like
    // a 'select' element has 'length' and 'item' properties on IE8
    (typeof obj.nodeType != 'number') &&
    (
      // a real array
      (// HTMLCollection/NodeList
      (Array.isArray(obj) ||
      // arguments
      ('callee' in obj) || 'item' in obj))
    )
  );
}

After compiling, it results into the following code:

function hasArrayNature(obj) {
  return // not null/false
  !!obj && (typeof obj == 'object' || typeof obj == 'function') && 'length' in obj && // not window
  !('setInterval' in obj) && typeof obj.nodeType != 'number' && (Array.isArray(obj) || 'callee' in obj || 'item' in obj);
}

So in all the situations this function returns undefined

I dealt with it by passing to admclean

'esprima': {
   'comment': false
 }

I don't know if this is a bug in Esprima or in Amdclean, anyway I guess it should be fixed.

alahtarin avatar Aug 25 '15 12:08 alahtarin