title: Uncaught TypeError: Cannot read property 'hasOwnProperty' of undefined
body: <p>I'm using fabric.js to draw some text on a canvas. I have a function to create a text label. I'd like to have labels run a function when they're selected. The syntax for this is <code>label.on('selected', functionToCall());</code> This works fine when I make the function an anonymous inner function, but when I break it out as a separate function, I get an Uncaught TypeError:</p>
  <blockquote>
  <p>Cannot read property 'hasOwnProperty' of undefined.</p>
  </blockquote>
  <p>What am I doing wrong?</p>
  <p>Below is the code which doesn't work for me. Here's the <a href="http://jsfiddle.net/R2mMt/" rel="nofollow noreferrer">broken code</a> on jsfiddle, and a version set up with an <a href="http://jsfiddle.net/MUqL5/" rel="nofollow noreferrer">anonymous function</a> which works.</p>
  <pre><code>&quot;use strict&quot;;
  
  var canvas = new fabric.Canvas('c', {selection: false}),
    position = 50;
  
  function onLabelSelection(theLabel) {
    if (theLabel.hasOwnProperty('edge')) {
      selectedEdge = theLabel.edge;
    } else {
      selectedEdge = null;
    }
  }
  
  function createLabel() {
    var label;
      
    label = new fabric.Text('Hello World', {
      left: position,
      top: position
    });
    position += 50;
      
    label.edge = null;
  
    label.on('selected', onLabelSelection(this));
  
    return label;
  }
  
  canvas.on('mouse:up', function() {
    var newLabel = createLabel(); 
    canvas.add(newLabel);
  });
  </code></pre>