Ok peep's I've recently been learning about custom elements ie: <x-foo>
.
I found that they have lifecycle callbacks, a series of listeners that can be attached to the element in order to further process it relative to its' current stage ie:
- Created
- Attached
- Detached
- Attribute Changed
eg:
var proto = Object.create(HTMLElement.prototype);
proto.createdCallback = function() {...};
proto.attachedCallback = function() {...};
var XFoo = document.registerElement('x-foo', {prototype: proto});
elm = new XFoo();
par.appendChild(elm);
My Question...
These callbacks seem to be specific to custom elements. So how do I achieve a similar result for standard/non-custom elements. ie:
var proto = HTMLDivElement.prototype;
proto.createdCallback = function() {...};
proto.attachedCallback = function() {...};
div = document.cerateElement('div');
par.appendChild(elm);