<commit_before>/*-----------------------------------------------------------------------------
| Copyright (c) 2014-2015, <NAME>
|
| Distributed under the terms of the BSD 3-Clause License.
|
| The full license is in the file LICENSE, distributed with this software.
|----------------------------------------------------------------------------*/
module phosphor.virtualdom {

import Queue = collections.Queue;

import IMessage = core.IMessage;
import Message = core.Message;
import postMessage = core.postMessage;
import sendMessage = core.sendMessage;

import emptyObject = utility.emptyObject;


/**
 * A singleton 'update-request' message.
 */
var MSG_UPDATE_REQUEST = new Message('update-request');

/**
 * A singleton 'before-render' message.
 */
var MSG_BEFORE_RENDER = new Message('before-render');

/**
 * A singleton 'after-render' message.
 */
var MSG_AFTER_RENDER = new Message('after-render');


/**
 * A component which renders its content using the virtual DOM.
 *
 * User code should subclass this class and reimplement the `render`
 * method to generate the virtual DOM content for the component.
 */
export
class Component<T extends IData> extends BaseComponent<T> {
  /**
   * Dispose of the resources held by the component.
   */
  dispose(): void {
    this._refs = null;
    super.dispose();
  }

  /**
   * Get the current refs mapping for the component.
   */
  get refs(): any {
    return this._refs;
  }

  /**
   * Schedule an update for the component.
   *
   * This should be called whenever the internal state of the component
   * has changed such that it requires the component to be re-rendered,<commit_msg>create a Component node from static `tagName` and `className` properties<commit_after>/*-----------------------------------------------------------------------------
| Copyright (c) 2014-2015, <NAME>
|
| Distributed under the terms of the BSD 3-Clause License.
|
| The full license is in the file LICENSE, distributed with this software.
|----------------------------------------------------------------------------*/
module phosphor.virtualdom {

import Queue = collections.Queue;

import IMessage = core.IMessage;
import Message = core.Message;
import postMessage = core.postMessage;
import sendMessage = core.sendMessage;

import emptyObject = utility.emptyObject;


/**
 * A singleton 'update-request' message.
 */
var MSG_UPDATE_REQUEST = new Message('update-request');

/**
 * A singleton 'before-render' message.
 */
var MSG_BEFORE_RENDER = new Message('before-render');

/**
 * A singleton 'after-render' message.
 */
var MSG_AFTER_RENDER = new Message('after-render');


/**
 * A component which renders its content using the virtual DOM.
 *
 * User code should subclass this class and reimplement the `render`
 * method to generate the virtual DOM content for the component.
 */
export
class Component<T extends IData> extends BaseComponent<T> {
  /**
   * The tag name to use when creating the component node.
   *
   * This may be reimplemented by a subclass.
   */
  static tagName = 'div';

  /**
   * The initial class name for the component node.
   *
   * This may be reimplemented by a subclass.
   */
  static className = '';

  /**
   * Create the DOM node for a component.
   *
   * This method creates the DOM node from the `className` and `tagName`
   * properties. A subclass will not typically reimplement this method.
   */
  static createNode(): HTMLElement {
    var node = document.createElement(this.tagName);
    node.className = this.className;
    return node;
  }

  /**
   * Dispose of the resources held by the component.
   */
  dispose(): void {
    this._refs = null;
    super.dispose();
  }

  /**
   * Get the current refs mapping for the component.
   */
  get refs(): any {
    return this._refs;
  }

  /**
   * Schedule an update for the component.
   *
   * This should be called whenever the internal state of the component
   * has changed such that it requires the component to be re-rendered,
{'fraction_non_alphanumeric': 0.1706827309236948, 'fraction_numerical': 0.004518072289156626, 'mean_word_length': 2.4773123909249564, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '5080876', 'n_tokens_mistral': 1096, 'n_tokens_neox': 1047, 'n_words': 404}