|
10 | 10 | d3_style_setProperty.call(this, name, value + "", priority); |
11 | 11 | }; |
12 | 12 | } |
13 | | -d3 = {version: "2.2.0"}; // semver |
| 13 | +d3 = {version: "2.2.1"}; // semver |
| 14 | +var d3_array = d3_arraySlice; // conversion for NodeLists |
| 15 | + |
| 16 | +function d3_arrayCopy(pseudoarray) { |
| 17 | + var i = -1, n = pseudoarray.length, array = []; |
| 18 | + while (++i < n) array.push(pseudoarray[i]); |
| 19 | + return array; |
| 20 | +} |
| 21 | + |
| 22 | +function d3_arraySlice(pseudoarray) { |
| 23 | + return Array.prototype.slice.call(pseudoarray); |
| 24 | +} |
| 25 | + |
| 26 | +try { |
| 27 | + d3_array(document.documentElement.childNodes)[0].nodeType; |
| 28 | +} catch(e) { |
| 29 | + d3_array = d3_arrayCopy; |
| 30 | +} |
| 31 | + |
14 | 32 | var d3_arraySubclass = [].__proto__? |
15 | 33 |
|
16 | 34 | // Until ECMAScript supports array subclassing, prototype injection works well. |
@@ -1254,7 +1272,7 @@ d3_selectionPrototype.selectAll = function(selector) { |
1254 | 1272 | for (var j = -1, m = this.length; ++j < m;) { |
1255 | 1273 | for (var group = this[j], i = -1, n = group.length; ++i < n;) { |
1256 | 1274 | if (node = group[i]) { |
1257 | | - subgroups.push(subgroup = selector.call(node, node.__data__, i)); |
| 1275 | + subgroups.push(subgroup = d3_array(selector.call(node, node.__data__, i))); |
1258 | 1276 | subgroup.parentNode = node; |
1259 | 1277 | } |
1260 | 1278 | } |
@@ -1738,16 +1756,18 @@ var d3_selectionRoot = d3_selection([[document]]); |
1738 | 1756 | d3_selectionRoot[0].parentNode = document.documentElement; |
1739 | 1757 |
|
1740 | 1758 | // TODO fast singleton implementation! |
| 1759 | +// TODO select(function) |
1741 | 1760 | d3.select = function(selector) { |
1742 | 1761 | return typeof selector === "string" |
1743 | 1762 | ? d3_selectionRoot.select(selector) |
1744 | 1763 | : d3_selection([[selector]]); // assume node |
1745 | 1764 | }; |
1746 | 1765 |
|
| 1766 | +// TODO selectAll(function) |
1747 | 1767 | d3.selectAll = function(selector) { |
1748 | 1768 | return typeof selector === "string" |
1749 | 1769 | ? d3_selectionRoot.selectAll(selector) |
1750 | | - : d3_selection([selector]); // assume node[] |
| 1770 | + : d3_selection([d3_array(selector)]); // assume node[] |
1751 | 1771 | }; |
1752 | 1772 | function d3_transition(groups, id) { |
1753 | 1773 | d3_arraySubclass(groups, d3_transitionPrototype); |
@@ -3401,7 +3421,7 @@ function d3_svg_mousePoint(container, e) { |
3401 | 3421 | }; |
3402 | 3422 | d3.svg.touches = function(container) { |
3403 | 3423 | var touches = d3.event.touches; |
3404 | | - return touches ? Array.prototype.map.call(touches, function(touch) { |
| 3424 | + return touches ? d3_array(touches).map(function(touch) { |
3405 | 3425 | var point = d3_svg_mousePoint(container, touch); |
3406 | 3426 | point.identifier = touch.identifier; |
3407 | 3427 | return point; |
|
0 commit comments