Skip to content

Commit

Permalink
Fix a bug in d3.interpolateString.
Browse files Browse the repository at this point in the history
The regular expression wasn't being reset, so we weren't always finding numbers!
  • Loading branch information
mbostock committed Apr 14, 2011
1 parent 1266373 commit dd5b21a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
4 changes: 3 additions & 1 deletion d3.js
Expand Up @@ -551,6 +551,9 @@ d3.interpolateString = function(a, b) {
n, // q.length
o;

// Reset our regular expression!
d3_interpolate_number.lastIndex = 0;

// Find all numbers in b.
for (i = 0; m = d3_interpolate_number.exec(b); ++i) {
if (m.index) s.push(b.substring(s0, s1 = m.index));
Expand Down Expand Up @@ -686,7 +689,6 @@ d3.interpolateObject = function(a, b) {
}

var d3_interpolate_number = /[-+]?(?:\d+\.\d+|\d+\.|\.\d+|\d+)(?:[eE][-]?\d+)?/g,
d3_interpolate_digits = /[-+]?\d*\.?\d*(?:[eE][-]?\d+)?(.*)/,
d3_interpolate_rgb = {background: 1, fill: 1, stroke: 1};

function d3_interpolateByName(n) {
Expand Down

0 comments on commit dd5b21a

Please sign in to comment.