Change behavior of a Leaflet class via include()
<p>You can change the behavior of a Leaflet.js class by <a href="http://leafletjs.com/reference-1.0.0.html#class-include" rel="nofollow noreferrer">including a mixin</a>. </p>

<p>The tutorial <a href="http://leafletjs.com/examples/extending/extending-1-classes.html#lclassinclude" rel="nofollow noreferrer">Extending Leaflet: Class Theory</a> says:</p>

<blockquote>
  <p>If a class is already defined, existing properties/methods can be redefined, or new ones can be added by using .include():</p>
</blockquote>

<p>However when attempting to do this, I get a <code>Maximum call stack size exceeded</code> error.</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>var DemoClass = L.Class.extend({
  value: 42,
  demoMethod: function() {
    return this.value;
  }
});

DemoClass.include({
  demoMethod: function() {
    return DemoClass.prototype.demoMethod.call(this) * 2;
  },
  secondMethod: function() {
    return this.value;
  }
});

var instance = new DemoClass();
console.log("value=" + instance.value);
console.log("secondMethod()=" + instance.secondMethod());
console.log("demoMethod()=" + instance.demoMethod()); // gives a call stack exceeded</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://unpkg.com/leaflet@1.0.1/dist/leaflet.js"&gt;&lt;/script&gt;</code></pre>
</div>
</div>
</p>

<p>If it's relevant, the actual code is overriding <code>L.Marker.onAdd()</code>.</p>