text() calls don't work on HTML elements
Closed this issue · 2 comments
sun16 commented
IE7/8 doesn't support the textContent attribute (see selection-text.js).
var div = d3.select('body').append('div');
div.text('hi');
console.log(div.text()); // should print hi
Instead, I recommend using innerText as it's the property that mimics textContent the closest.
References:
http://clubajax.org/plain-text-vs-innertext-vs-textcontent/
http://d.hatena.ne.jp/cou929_la/20110517/1305644081
sun16 commented
Unfortunately DOM elements in IE7 aren't the same as regular JS objects , so you can't just change their prototype and shim textContent. I simply replace textContent with innerText in my build.