# Code coverage report for lib/components/base.js

## Statements: 92.86% (13 / 14) Branches: 50% (1 / 2) Functions: 100% (6 / 6) Lines: 100% (13 / 13) Ignored: none

All files » lib/components/ » base.js

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    611

    1

    49
    49
    49
    49
    49
    49

    49

    1

    52

    40

    1

     var protoclass = require("protoclass"),
    _bind          = require("../utils/bind");

    /**
     */

    function Component(options) {

      this.attributes    = options.attributes;
      this.childTemplate = options.childTemplate;
      this.view          = options.view;
      this.section       = options.section;
      this.nodeFactory   = this.view.template.nodeFactory;
      this.didChange     = _bind(this.didChange, this);

      // initialize the DOM elements
      this.initialize();
    }

    /**
     */

    module.exports = protoclass(Component, {

      /**
       */

      initialize: function() {
        // override me - this is where the DOM elements should be added to the
        // section
      },

      /**
       */

      bind: function() {
        this.update();
      },

      /**
       */

      didChange: function() {
        this.view.runloop.deferOnce(this);
      },

      /**
       */

      unbind: function() {
        Iif (this._changeListener) this._changeListener.dispose();
      },

      /**
       */

      update: function() {
        // apply DOM changes here
      }
    });