I'd like to put a getter / setter on every html elements title property for example.
I'll be honnest, I don't really know what I'm doing but I've tried redefining the title property but it's not writable so I tried to reassign the Element.property like this :
var o = {};
Object.defineProperty(o, 'innerText', {
configurable: true, enumerable: true,
get: function() { return this.__innerText__; },
set: function(y) { console.log('setting title'); this.__innerText__ = y; }
});
Object.defineProperty(o, '__innerText__', {
configurable: true, writable: true, enumerable: true, value :""
});
Element.prototype = Object.assign(o, Element.prototype);
let div = document.createElement('div')
document.body.appendChild(div);
div.innerText = "hey"
// Uncaught TypeError: Illegal invocation
// at Function.assign (<anonymous>)