eliace/ergo-js

View on GitHub
js/includes/placeholder.js

Summary

Maintainability
A
55 mins
Test Coverage

Ergo.alias('includes:placeholder', {

//  overrides: {

    set placeholder(v) {
      var tag = this.el.prop('tagName').toLowerCase();
      if(tag == 'input' || tag == 'textarea') {
        if(v != null) {
          this.el.prop('placeholder', v);
        }
        else {
          this.el.removeProp('placeholder');
        }
      }
      else {
        if(v != null) {
          this.el.attr('data-ph', v);
          this.states.set('ph');
        }
        else {
          this.el.removeAttr('data-ph');
          this.states.unset('ph');
        }
      }
    }

//  }

});