{"action":"created","issue":{"url":"https://api.github.com/repos/d3/d3-selection/issues/44","labels_url":"https://api.github.com/repos/d3/d3-selection/issues/44/labels{/name}","comments_url":"https://api.github.com/repos/d3/d3-selection/issues/44/comments","events_url":"https://api.github.com/repos/d3/d3-selection/issues/44/events","html_url":"https://github.com/d3/d3-selection/issues/44","id":120490672,"number":44,"title":"Setting NodeList `length` in strict mode throws TypeError","user":{"login":"akre54","id":931368,"avatar_url":"https://avatars.githubusercontent.com/u/931368?v=3","gravatar_id":"","url":"https://api.github.com/users/akre54","html_url":"https://github.com/akre54","followers_url":"https://api.github.com/users/akre54/followers","following_url":"https://api.github.com/users/akre54/following{/other_user}","gists_url":"https://api.github.com/users/akre54/gists{/gist_id}","starred_url":"https://api.github.com/users/akre54/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/akre54/subscriptions","organizations_url":"https://api.github.com/users/akre54/orgs","repos_url":"https://api.github.com/users/akre54/repos","events_url":"https://api.github.com/users/akre54/events{/privacy}","received_events_url":"https://api.github.com/users/akre54/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-12-04T21:34:50Z","updated_at":"2015-12-04T21:46:49Z","closed_at":null,"body":"I'm updating an app from d3 3.5.x and ran into an issue using selections in strict mode.\r\n\r\nMy code is a basic selection / data binding: `selection.selectAll('div').data(data)`. Data is an Array and the selection length is equal to the data length (4).\r\n\r\nThis worked correctly in 3.5.x with strict mode. Now I'm getting a TypeError in the data method when it tries to set `update.length = dataLength` ([src](https://github.com/d3/d3-selection/blob/v0.4.12/src/selection-data.js#L93)). \r\n\r\n[Here's a reproducible test case](https://gist.github.com/akre54/4a6116938e76d4701a0b), but the basic gist is this:\r\n\r\n```js\r\nvar nl = document.querySelectorAll('div');\r\n\r\nconsole.log(nl.length); // 4\r\nnl.length = 4;\r\nconsole.log(nl.length); // 4, doesn't change length but silently swallows error\r\n\r\n'use strict'\r\nnl.length = 4\r\n// TypeError: Cannot set property length of #<NodeList> which has only a getter\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/d3/d3-selection/issues/comments/162090978","html_url":"https://github.com/d3/d3-selection/issues/44#issuecomment-162090978","issue_url":"https://api.github.com/repos/d3/d3-selection/issues/44","id":162090978,"user":{"login":"mbostock","id":230541,"avatar_url":"https://avatars.githubusercontent.com/u/230541?v=3","gravatar_id":"","url":"https://api.github.com/users/mbostock","html_url":"https://github.com/mbostock","followers_url":"https://api.github.com/users/mbostock/followers","following_url":"https://api.github.com/users/mbostock/following{/other_user}","gists_url":"https://api.github.com/users/mbostock/gists{/gist_id}","starred_url":"https://api.github.com/users/mbostock/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mbostock/subscriptions","organizations_url":"https://api.github.com/users/mbostock/orgs","repos_url":"https://api.github.com/users/mbostock/repos","events_url":"https://api.github.com/users/mbostock/events{/privacy}","received_events_url":"https://api.github.com/users/mbostock/received_events","type":"User","site_admin":false},"created_at":"2015-12-04T21:46:49Z","updated_at":"2015-12-04T21:46:49Z","body":"Also, it looks like you’re trying to call selection.text on the enter selection before appending. That shouldn’t fall, but it also won’t have any effect because you’re setting the `textContent` property of a [placeholder node](https://github.com/d3/d3-selection/blob/master/src/selection-data.js#L167). You’ll want to say something like this instead:\r\n\r\n```js\r\nselectAll('p')\r\n    .data(data)\r\n  .enter().append('p')\r\n    .text(d => d)\r\n```"}}