I cannot figured out why I got Uncaught TypeError: Illegal invocation
error when calling getAttribute
from a Javascript proxy.
https://jsbin.com/raqafazixe/1/edit?html,js,console
Here's the HTML code:
<div id="a"></div>
Here's the Javascript code:
const a = document.querySelector('#a');
console.log(a.getAttribute('id'));
console.log(new Proxy(a, {}).getAttribute('id'));
And here's the output:
a
Uncaught TypeError: Illegal invocation