/// <reference path="../../typings/angular2/angular2.d.ts" />
import {
Component,
View,
Parent,
onInit
} from 'angular2/angular2';

import {$famous} from '../service/famous';
import {FaNode} from './node';

// FaDomElement

@Component({
  selector: 'fa-element',
  properties: ['properties', 'content']
})

@View({
  template: ``
})

export class FaDomElement {
  element: Object;
  properties: Object;
  content: String;
  constructor(@Parent() parent:FaNode) {

    var DOMElement = famous.domRenderables.DOMElement;
          // add an element
    this.element = new DOMElement(parent.node);

  }

  onInit() {

    let elem = this;
    this.content ? this.element.setContent(elem.content) : false;
    // set properties on element when specified in attribute.
    for (var key in this.properties) {
        if (this.properties.hasOwnProperty(key)) {
             this.element.setProperty(key.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase(),this.properties[key]);
        }
    }

  }
}
