Code coverage report for lib/template/vnode/element/componentHydrator.js

Statements: 27.78% (5 / 18)      Branches: 0% (0 / 2)      Functions: 0% (0 / 3)      Lines: 29.41% (5 / 17)      Ignored: none     

All files » lib/template/vnode/element/ » componentHydrator.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 531 1 1         1                     1                                                                    
var protoclass        = require("protoclass");
var AttributesBinding = require("./attributesBinding");
var _extend           = require("../../../utils/extend");
 
/**
 */
 
function ComponentHydrator(name, attributes, childTemplate, section, componentClass) {
  this.name           = name;
  this.attributes     = attributes;
  this.childTemplate  = childTemplate;
  this.section        = section;
  this.componentClass = componentClass;
}
 
/**
 */
 
module.exports = protoclass(ComponentHydrator, {
 
  /**
   */
 
  initialize: function() {
    this.sectionMarker = this.section.createMarker();
  },
 
  /**
   */
 
  hydrate: function(view) {
    this.childTemplate.accessor = view.accessor;
 
    var clonedSection = this.sectionMarker.getSection(view.rootNode);
 
    // TODO - bind script attrs to these attrs
    var attributes = _extend({}, this.attributes);
 
    var component = new this.componentClass({
      name          : this.name,
      section       : clonedSection,
      attributes    : attributes,
      view          : view,
      childTemplate : this.childTemplate
    });
 
    view.bindings.push(new AttributesBinding(attributes, this.attributes, component, view));
 
    // is it bindable?
    if (component.bind) view.bindings.push(component);
  }
});