@caption HTML Element wrapper

@readme
This class provides helper functions for DOM manipulation.

@aliases elementWrapper elementWrapperClass
@class html5.lib.wrap
@type class
 Class {{{1
function init(tag, attrs, params) {  // {{{2
/**
 * HTML Element wrapper constructor.
 *
 * @todo
 * Templates must have single root.
 *
 * @param tag {String|Object} Tag or element to be wrapped or created
 * @param [attrs] {String|Object} Attributes of element, supplied string is used as element class
 * @param [params] {String|Object} Parameters of element wrapper, string is used as `element.textContent`
 *
 * @method constructor
 */

  switch (typeof (tag || undefined)) {
  case 'string':
    if (tag.charAt(0) === '<') {
      var t = document.createElement('template');
      t.innerHTML = tag;
      this.el = document.adoptNode(t.content).firstElementChild;
      break;
    }

    if (tag in exports.controls) {
      this.control = exports.controls[tag];

      if (this.control.template) {
        this.el = document.importNode(this.control.template.content, true).firstElementChild;
      } else {
        this.el = document.createElement(tag);
      }

      this.el.ose = this;
      break;
    }

    this.el = document.createElement(tag);
    break;
  case 'object':
    if (typeof tag.tagName === 'string') {
      if (tag.tagName === 'TEMPLATE') {
        this.el = document.adoptNode(tag.content).firstElementChild;
        break;
      }

      this.el = tag;
      break;
    }

    // NO BREAK
  default:
    throw O.log.error(this, 'INVALID_ARGS', arguments);
  }

  if (this.control && this.control.init) {
    this.control.init(this);
  }

  this.attrs(attrs);
  this.params(params);
}