<commit_before>import {List} from 'immutable';

declare let $0: HTMLElement;
declare let ng: { probe: Function };

let list = List<String>();

export function getComponentContents(): Object {
  
  function getDebugElement(node) {
    let debugElement = ng.probe(node);
  
    if (!debugElement) {
      // Might be a child of a DocumentFragment...
      while (node && node.nodeType === 1) { 
        node = node.parentNode; 
      }
      
      if (node && node.nodeType === 11) { 
        node = (node.parentNode || node.host); 
      }
      
      return getDebugElement(node);
    }
    
    return debugElement;
  }

  if (ng && ng.probe && $0) {
    // TODO: can we move this scope export into updateElementProperties
    let debugElement = getDebugElement($0);
    
    // Export debugElement to the console
    Object.defineProperty(window, '$debugElement', {
      configurable: true,
      value: debugElement
    });

    return {
      debugElement: debugElement,
      cmpChildren: debugElement.componentViewChildren,
      cmpInstance: debugElement.componentInstance,
      elementReference: debugElement.elementRef,
      nativeElement: debugElement.nativeElement,
      parentView: debugElement._parentView
    };

  } else {
    return {};
  }
}<commit_msg>Cleanup data shown on Component Inspector Pane<commit_after>import {List} from 'immutable';

declare let $0: HTMLElement;
declare let ng: { probe: Function };

let list = List<String>();

export function getComponentContents(): Object {
  
  function getDebugElement(node) {
    let $a = ng.probe(node);
  
    if (!$a) {
      // Might be a child of a DocumentFragment...
      while (node && node.nodeType === 1) { 
        node = node.parentNode; 
      }
      
      if (node && node.nodeType === 11) { 
        node = (node.parentNode || node.host); 
      }
      
      return getDebugElement(node);
    }
    
    return $a;
  }

  if (ng && ng.probe && $0) {
    // TODO: can we move this scope export into updateElementProperties
    let $a = getDebugElement($0);
    
    // Export debugElement to the console
    Object.defineProperty(window, '$a', {
      configurable: true,
      value: $a
    });

    return {
      componentInstance: $a.componentInstance,
      componentViewChildren: $a.componentViewChildren,
      elementRef: $a.elementRef,
      nativeElement: $a.nativeElement,
      $a: $a
    };

  } else {
    return {};
  }
}
{'fraction_non_alphanumeric': 0.1176954732510288, 'fraction_numerical': 0.0049382716049382715, 'mean_word_length': 2.5028818443804033, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6533992', 'n_tokens_mistral': 728, 'n_tokens_neox': 706, 'n_words': 190}