# Code coverage report for lib/template/vnode/element/attributeHydrator.js

## Statements: 100% (10 / 10) Branches: 100% (0 / 0) Functions: 100% (3 / 3) Lines: 100% (10 / 10) Ignored: none

All files » lib/template/vnode/element/ » attributeHydrator.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
    331

    1
    39
    39
    39
    39

    1

    39

    39

    39

     var protoclass        = require("protoclass"),
    utils                 = require("../../../utils"),
    createDocumentSection = require("document-section"),
    BindableObject        = require("bindable-object"),
    AttributesBinding     = require("./attributesBinding");

    function AttributeHydrator (attrClass, key, value, node) {
      this.node      = node;
      this.key       = key;
      this.value     = value;
      this.attrClass = attrClass;
    }

    module.exports = protoclass(AttributeHydrator, {
      initialize: function () {
        this.nodePath = utils.getNodePath(this.node);
      },
      hydrate: function (view) {

        var attribute = new this.attrClass({

          // attribute handlers can only be added to real elements for now since
          // components can have any number of dynamic text/element children - which won't
          // have attribute handlers attached to them such as onClick, onEnter, etc.
          node: utils.getNodeByPath(view.rootNode, this.nodePath),
          view: view,
          key: this.key,
          value: this.value
        });

        view.bindings.push(attribute);
      }
    });