tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

component.js (1250B)


      1 /*
      2 * class
      3 */
      4 
      5 class Punny extends Component {
      6  constructor(props) {
      7    super();
      8    this.onClick = this.onClick.bind(this);
      9  }
     10 
     11  componentDidMount() {}
     12 
     13  onClick() {}
     14 
     15  renderMe() {
     16    return <div onClick={this.onClick} />;
     17  }
     18 
     19  render() {}
     20 }
     21 
     22 /*
     23 * CALL EXPRESSIONS - createClass, extend
     24 */
     25 
     26 const TodoView = Backbone.View.extend({
     27  tagName: "li",
     28 
     29  render: function() {
     30    console.log("yo");
     31  }
     32 });
     33 
     34 const TodoClass = createClass({
     35  tagName: "li",
     36 
     37  render: function() {
     38    console.log("yo");
     39  }
     40 });
     41 
     42 TodoClass = createClass({
     43  tagName: "li",
     44 
     45  render: function() {
     46    console.log("yo");
     47  }
     48 });
     49 
     50 app.TodoClass = createClass({
     51  tagName: "li",
     52 
     53  render: function() {
     54    console.log("yo");
     55  }
     56 });
     57 
     58 /*
     59 * PROTOTYPE
     60 */
     61 
     62 function Button() {
     63  if (!(this instanceof Button)) return new Button();
     64  this.color = null;
     65  Nanocomponent.call(this);
     66 }
     67 
     68 Button.prototype = Object.create(Nanocomponent.prototype);
     69 
     70 var x = function() {};
     71 
     72 Button.prototype.createElement = function(color) {
     73  this.color = color;
     74  return html`
     75    <button style="background-color: ${color}">
     76      Click Me
     77    </button>
     78  `;
     79 };
     80 
     81 // Implement conditional rendering
     82 Button.prototype.update = function(newColor) {
     83  return newColor !== this.color;
     84 };