Can I define custom functions on custom elements?
Sort of:
var proto = Object.create(HTMLElement.prototype);
proto.customMethod = function () { ... };
document.registerElement('custom-el', {
prototype: proto
});
And the method call for the element:
var istance = document.createElement('custom-el');
instance.customMethod();
source
share