[Technical] addEventListener can no longer be overriden
-
Hey!
Here is Matthew, developer behind the Real Cookie Banner plugin. ??
I have found an issue with NitroPack which does not allow our main feature to work as expected. In technical words, we are trying to override the
window.addEventListener
anddocument.addEventListener
to delay execution of blocked content which needs user consent (GDPR).Unfortunately, we get the following error:
TypeError: Cannot assign to read only property 'addEventListener' of object '#<HTMLDocument>'
The root cause for this is NitroPack and how it overrides the
addEventListener
functionality, too:Is it intentional, that
writable
,configurable
andenumerable
are disabled through yourdefineProperty
? If you pass onlyvalue
toObject.defineProperty
, all this fields default tofalse
. By default, browsers are defining.addEventListener
aswritable
,configurable
andenumarable
totrue
.I think this is a bug, and you should consider overriding
addEventListener
in the following way to not modify the object descriptor itself:window.addEventListener = function() { ...
Regards,
Matthew ??
- The topic ‘[Technical] addEventListener can no longer be overriden’ is closed to new replies.