{"action":"created","issue":{"url":"https://api.github.com/repos/jsdom/jsdom/issues/2158","repository_url":"https://api.github.com/repos/jsdom/jsdom","labels_url":"https://api.github.com/repos/jsdom/jsdom/issues/2158/labels{/name}","comments_url":"https://api.github.com/repos/jsdom/jsdom/issues/2158/comments","events_url":"https://api.github.com/repos/jsdom/jsdom/issues/2158/events","html_url":"https://github.com/jsdom/jsdom/issues/2158","id":299895921,"number":2158,"title":"Use ElementImpl.prototype.setAttribute/getAttribute inside of HTML properties","user":{"login":"davidturissini","id":910607,"avatar_url":"https://avatars0.githubusercontent.com/u/910607?v=4","gravatar_id":"","url":"https://api.github.com/users/davidturissini","html_url":"https://github.com/davidturissini","followers_url":"https://api.github.com/users/davidturissini/followers","following_url":"https://api.github.com/users/davidturissini/following{/other_user}","gists_url":"https://api.github.com/users/davidturissini/gists{/gist_id}","starred_url":"https://api.github.com/users/davidturissini/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davidturissini/subscriptions","organizations_url":"https://api.github.com/users/davidturissini/orgs","repos_url":"https://api.github.com/users/davidturissini/repos","events_url":"https://api.github.com/users/davidturissini/events{/privacy}","received_events_url":"https://api.github.com/users/davidturissini/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-02-24T01:07:48Z","updated_at":"2018-02-24T01:12:30Z","closed_at":null,"author_association":"NONE","body":"### Basic info:\r\n\r\nJSDOM HTML property setters/getters internally call `this.setAttribute` and `this.getAttribute`, respectively.\r\n\r\nThis is different from browser behavior, which do not call `setAttribute` and `getAttribute` directly on the Element itself. I think JSDOM can preserve this by calling `getAttribute` and `setAttribute` on `ElementImpl.prototype` directly.\r\n\r\nFor an example of there this happens in JSDOM, please see https://github.com/jsdom/jsdom/blob/master/lib/jsdom/living/nodes/HTMLElement-impl.js#L78\r\n\r\nFor example of browser behavior, see below.\r\n\r\n- **Node.js version:** 8.7.0\r\n- **jsdom version:** 11.6.2\r\n\r\n### Minimal reproduction case\r\n\r\n```js\r\nconst { JSDOM } = require('jsdom');\r\nconst dom = new JSDOM('');\r\nvar div = dom.window.document.createElement('div');\r\ndiv.setAttribute = function () {\r\n  console.log('I should not be called')\r\n}\r\n\r\nvar descSet = Object.getOwnPropertyDescriptor(dom.window.HTMLElement.prototype, 'title').set;\r\n\r\ndescSet.call(div, 'new title');\r\n```\r\n\r\n### How does similar code behave in browsers?\r\n\r\nhttp://jsbin.com/koyilegopa/edit?html,js,console,output\r\n"},"comment":{"url":"https://api.github.com/repos/jsdom/jsdom/issues/comments/368183504","html_url":"https://github.com/jsdom/jsdom/issues/2158#issuecomment-368183504","issue_url":"https://api.github.com/repos/jsdom/jsdom/issues/2158","id":368183504,"user":{"login":"TimothyGu","id":1538624,"avatar_url":"https://avatars2.githubusercontent.com/u/1538624?v=4","gravatar_id":"","url":"https://api.github.com/users/TimothyGu","html_url":"https://github.com/TimothyGu","followers_url":"https://api.github.com/users/TimothyGu/followers","following_url":"https://api.github.com/users/TimothyGu/following{/other_user}","gists_url":"https://api.github.com/users/TimothyGu/gists{/gist_id}","starred_url":"https://api.github.com/users/TimothyGu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TimothyGu/subscriptions","organizations_url":"https://api.github.com/users/TimothyGu/orgs","repos_url":"https://api.github.com/users/TimothyGu/repos","events_url":"https://api.github.com/users/TimothyGu/events{/privacy}","received_events_url":"https://api.github.com/users/TimothyGu/received_events","type":"User","site_admin":false},"created_at":"2018-02-24T01:12:30Z","updated_at":"2018-02-24T01:12:30Z","author_association":"MEMBER","body":"> JSDOM HTML property setters/getters internally call `this.setAttribute` and `this.getAttribute`, respectively.\r\n\r\nWhen you see `getAttribute` or `setAttribute` in the code, it should always refers to the impl version of the function, since `this` is an instance of `HTMLElementImpl` rather than `HTMLElement`, and thus `ElementImpl` rather than `Element`.\r\n\r\nCan you replace `console.log('I should not be called')` with `console.trace()` and post the result here?"}}
{"actor":{"display_login":"TimothyGu"}}