Skip to content

Instantly share code, notes, and snippets.

@yonester
Last active November 4, 2016 15:05
Show Gist options
  • Save yonester/cc506d7a23aaa13f7663d553d0a1ed6a to your computer and use it in GitHub Desktop.
Save yonester/cc506d7a23aaa13f7663d553d0a1ed6a to your computer and use it in GitHub Desktop.
Can we interpolate "transform" in jsdom?
var jsdom = require('jsdom'),
d3 = require('d3');
var document = jsdom.jsdom();
var rect = d3.select(document.body).append('svg').append('rect');
// This works...
rect
.attr('width', 0)
.transition()
.attr('width', 100);
// This doesn't...
rect
.attr('transform', 'translate(0,0)')
.transition()
.attr('transform', 'translate(10,10)');
// var g = d3_document.createElementNS(d3.ns.prefix.svg, "g");
// ^
//
// TypeError: Cannot read property 'createElementNS' of undefined
// at Object.d3.transform (/Dev/node_modules/d3/d3.js:5946:24)
// at d3_interpolateTransform (/Dev/node_modules/d3/d3.js:6050:12)
// at HTMLUnknownElement.<anonymous> (/Dev/node_modules/d3/d3.js:8755:32)
// at d3_Map.<anonymous> (/Dev/node_modules/d3/d3.js:8946:27)
// at d3_Map.d3_class.forEach (/Dev/node_modules/d3/d3.js:341:33)
// at start (/Dev/node_modules/d3/d3.js:8945:24)
// at Object.schedule (/Dev/node_modules/d3/d3.js:8913:36)
// at d3_timer_mark (/Dev/node_modules/d3/d3.js:2166:35)
// at Timeout.d3_timer_step [as _onTimeout] (/Dev/node_modules/d3/d3.js:2147:15)
// at tryOnTimeout (timers.js:224:11)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment