d3-selection
Advanced tools
Comparing version 0.6.3 to 0.6.5
@@ -1,1 +0,1 @@ | ||
var version = "0.6.3"; export * from "../index"; export {version}; | ||
var version = "0.6.5"; export * from "../index"; export {version}; |
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : | ||
typeof define === 'function' && define.amd ? define('d3-selection', ['exports'], factory) : | ||
factory((global.d3_selection = {})); | ||
typeof define === 'function' && define.amd ? define(['exports'], factory) : | ||
(factory((global.d3_selection = {}))); | ||
}(this, function (exports) { 'use strict'; | ||
@@ -110,50 +110,351 @@ | ||
function dispatchEvent(node, type, params) { | ||
var window = defaultView(node), | ||
event = window.CustomEvent; | ||
function selector(selector) { | ||
return function() { | ||
return this.querySelector(selector); | ||
}; | ||
} | ||
if (event) { | ||
event = new event(type, params); | ||
} else { | ||
event = window.document.createEvent("Event"); | ||
if (params) event.initEvent(type, params.bubbles, params.cancelable), event.detail = params.detail; | ||
else event.initEvent(type, false, false); | ||
function selection_select(select) { | ||
if (typeof select !== "function") select = selector(select); | ||
for (var groups = this._nodes, update = this._update, m = groups.length, subgroups = new Array(m), j = 0; j < m; ++j) { | ||
for (var group = groups[j], n = group.length, subgroup = subgroups[j] = new Array(n), node, subnode, i = 0; i < n; ++i) { | ||
if ((node = group[i]) && (subnode = select.call(node, node.__data__, i, group))) { | ||
if ("__data__" in node) subnode.__data__ = node.__data__; | ||
if (update) update._nodes[j][i] = subnode; | ||
subgroup[i] = subnode; | ||
} | ||
} | ||
} | ||
node.dispatchEvent(event); | ||
return new Selection(subgroups, this._parents); | ||
} | ||
function dispatchConstant(type, params) { | ||
function selectorAll(selector) { | ||
return function() { | ||
return dispatchEvent(this, type, params); | ||
return this.querySelectorAll(selector); | ||
}; | ||
} | ||
function dispatchFunction(type, params) { | ||
function selection_selectAll(select) { | ||
if (typeof select !== "function") select = selectorAll(select); | ||
for (var groups = this._nodes, m = groups.length, subgroups = [], parents = [], j = 0; j < m; ++j) { | ||
for (var group = groups[j], n = group.length, node, i = 0; i < n; ++i) { | ||
if (node = group[i]) { | ||
subgroups.push(select.call(node, node.__data__, i, group)); | ||
parents.push(node); | ||
} | ||
} | ||
} | ||
return new Selection(subgroups, parents); | ||
} | ||
var matcher = function(selector) { | ||
return function() { | ||
return dispatchEvent(this, type, params.apply(this, arguments)); | ||
return this.matches(selector); | ||
}; | ||
}; | ||
if (typeof document !== "undefined") { | ||
var element$1 = document.documentElement; | ||
if (!element$1.matches) { | ||
var vendorMatches = element$1.webkitMatchesSelector | ||
|| element$1.msMatchesSelector | ||
|| element$1.mozMatchesSelector | ||
|| element$1.oMatchesSelector; | ||
matcher = function(selector) { | ||
return function() { | ||
return vendorMatches.call(this, selector); | ||
}; | ||
}; | ||
} | ||
} | ||
function selection_dispatch(type, params) { | ||
return this.each((typeof params === "function" | ||
? dispatchFunction | ||
: dispatchConstant)(type, params)); | ||
var matcher$1 = matcher; | ||
function selection_filter(match) { | ||
if (typeof match !== "function") match = matcher$1(match); | ||
for (var groups = this._nodes, m = groups.length, subgroups = new Array(m), j = 0; j < m; ++j) { | ||
for (var group = groups[j], n = group.length, subgroup = subgroups[j] = [], node, i = 0; i < n; ++i) { | ||
if ((node = group[i]) && match.call(node, node.__data__, i, group)) { | ||
subgroup.push(node); | ||
} | ||
} | ||
} | ||
return new Selection(subgroups, this._parents); | ||
} | ||
function selection_datum(value) { | ||
return arguments.length | ||
? this.property("__data__", value) | ||
: this.node().__data__; | ||
function arrayify(selection) { | ||
for (var groups = selection._nodes, j = 0, m = groups.length; j < m; ++j) { | ||
if (!Array.isArray(group = groups[j])) { | ||
for (var n = group.length, array = groups[j] = new Array(n), group, i = 0; i < n; ++i) { | ||
array[i] = group[i]; | ||
} | ||
} | ||
} | ||
return groups; | ||
} | ||
function remove() { | ||
var parent = this.parentNode; | ||
if (parent) parent.removeChild(this); | ||
function constant(x) { | ||
return function() { | ||
return x; | ||
}; | ||
} | ||
function selection_remove() { | ||
return this.each(remove); | ||
var keyPrefix = "$"; // Protect against keys like “__proto__”. | ||
function bindIndex(parent, update, enter, exit, data) { | ||
var i = 0, | ||
node, | ||
nodeLength = update.length, | ||
dataLength = data.length, | ||
minLength = Math.min(nodeLength, dataLength); | ||
// Clear the enter and exit arrays, and then initialize to the new length. | ||
enter.length = 0, enter.length = dataLength; | ||
exit.length = 0, exit.length = nodeLength; | ||
for (; i < minLength; ++i) { | ||
if (node = update[i]) { | ||
node.__data__ = data[i]; | ||
} else { | ||
enter[i] = new EnterNode(parent, data[i]); | ||
} | ||
} | ||
// Note: we don’t need to delete update[i] here because this loop only | ||
// runs when the data length is greater than the node length. | ||
for (; i < dataLength; ++i) { | ||
enter[i] = new EnterNode(parent, data[i]); | ||
} | ||
// Note: and, we don’t need to delete update[i] here because immediately | ||
// following this loop we set the update length to data length. | ||
for (; i < nodeLength; ++i) { | ||
if (node = update[i]) { | ||
exit[i] = update[i]; | ||
} | ||
} | ||
update.length = dataLength; | ||
} | ||
function bindKey(parent, update, enter, exit, data, key) { | ||
var i, | ||
node, | ||
dataLength = data.length, | ||
nodeLength = update.length, | ||
nodeByKeyValue = {}, | ||
keyValues = new Array(nodeLength), | ||
keyValue; | ||
// Clear the enter and exit arrays, and then initialize to the new length. | ||
enter.length = 0, enter.length = dataLength; | ||
exit.length = 0, exit.length = nodeLength; | ||
// Compute the keys for each node. | ||
for (i = 0; i < nodeLength; ++i) { | ||
if (node = update[i]) { | ||
keyValues[i] = keyValue = keyPrefix + key.call(node, node.__data__, i, update); | ||
// Is this a duplicate of a key we’ve previously seen? | ||
// If so, this node is moved to the exit selection. | ||
if (nodeByKeyValue[keyValue]) { | ||
exit[i] = node; | ||
} | ||
// Otherwise, record the mapping from key to node. | ||
else { | ||
nodeByKeyValue[keyValue] = node; | ||
} | ||
} | ||
} | ||
// Now clear the update array and initialize to the new length. | ||
update.length = 0, update.length = dataLength; | ||
// Compute the keys for each datum. | ||
for (i = 0; i < dataLength; ++i) { | ||
keyValue = keyPrefix + key.call(parent, data[i], i, data); | ||
// Is there a node associated with this key? | ||
// If not, this datum is added to the enter selection. | ||
if (!(node = nodeByKeyValue[keyValue])) { | ||
enter[i] = new EnterNode(parent, data[i]); | ||
} | ||
// Did we already bind a node using this key? (Or is a duplicate?) | ||
// If unique, the node and datum are joined in the update selection. | ||
// Otherwise, the datum is ignored, neither entering nor exiting. | ||
else if (node !== true) { | ||
update[i] = node; | ||
node.__data__ = data[i]; | ||
} | ||
// Record that we consumed this key, either to enter or update. | ||
nodeByKeyValue[keyValue] = true; | ||
} | ||
// Take any remaining nodes that were not bound to data, | ||
// and place them in the exit selection. | ||
for (i = 0; i < nodeLength; ++i) { | ||
if ((node = nodeByKeyValue[keyValues[i]]) !== true) { | ||
exit[i] = node; | ||
} | ||
} | ||
} | ||
function selection_data(value, key) { | ||
if (!value) { | ||
var data = new Array(this.size()), i = -1; | ||
this.each(function(d) { data[++i] = d; }); | ||
return data; | ||
} | ||
var bind = key ? bindKey : bindIndex, | ||
parents = this._parents, | ||
update = arrayify(this), | ||
enter = (this._enter = this.enter())._nodes, | ||
exit = (this._exit = this.exit())._nodes; | ||
if (typeof value !== "function") value = constant(value); | ||
for (var m = update.length, j = 0; j < m; ++j) { | ||
var group = update[j], | ||
parent = parents[j]; | ||
bind(parent, group, enter[j], exit[j], value.call(parent, parent && parent.__data__, j, parents), key); | ||
// Now connect the enter nodes to their following update node, such that | ||
// appendChild can insert the materialized enter node before this node, | ||
// rather than at the end of the parent node. | ||
for (var n = group.length, i0 = 0, i1 = 0, previous, next; i0 < n; ++i0) { | ||
if (previous = enter[j][i0]) { | ||
if (i0 >= i1) i1 = i0 + 1; | ||
while (!(next = group[i1]) && ++i1 < n); | ||
previous._next = next || null; | ||
} | ||
} | ||
} | ||
return this; | ||
} | ||
function EnterNode(parent, datum) { | ||
this.ownerDocument = parent.ownerDocument; | ||
this.namespaceURI = parent.namespaceURI; | ||
this._next = null; | ||
this._parent = parent; | ||
this.__data__ = datum; | ||
} | ||
EnterNode.prototype = { | ||
appendChild: function(child) { return this._parent.insertBefore(child, this._next); }, | ||
insertBefore: function(child, next) { return this._parent.insertBefore(child, next); }, | ||
querySelector: function(selector) { return this._parent.querySelector(selector); }, | ||
querySelectorAll: function(selector) { return this._parent.querySelectorAll(selector); } | ||
}; | ||
function sparse(update) { | ||
return new Array(update.length); | ||
} | ||
function selection_enter() { | ||
var enter = this._enter; | ||
if (enter) return this._enter = null, enter; | ||
enter = new Selection(this._nodes.map(sparse), this._parents); | ||
enter._update = this; | ||
return enter; | ||
} | ||
function selection_exit() { | ||
var exit = this._exit; | ||
if (exit) return this._exit = null, exit; | ||
return new Selection(this._nodes.map(sparse), this._parents); | ||
} | ||
function selection_order() { | ||
for (var groups = this._nodes, j = -1, m = groups.length; ++j < m;) { | ||
for (var group = groups[j], i = group.length - 1, next = group[i], node; --i >= 0;) { | ||
if (node = group[i]) { | ||
if (next && next !== node.nextSibling) next.parentNode.insertBefore(node, next); | ||
next = node; | ||
} | ||
} | ||
} | ||
return this; | ||
} | ||
function selection_sort(compare) { | ||
if (!compare) compare = ascending; | ||
function compareNode(a, b) { | ||
return a && b ? compare(a.__data__, b.__data__) : !a - !b; | ||
} | ||
for (var groups = arrayify(this), j = 0, m = groups.length; j < m; ++j) { | ||
groups[j].sort(compareNode); | ||
} | ||
return this.order(); | ||
} | ||
function ascending(a, b) { | ||
return a < b ? -1 : a > b ? 1 : a >= b ? 0 : NaN; | ||
} | ||
function selection_call() { | ||
var callback = arguments[0]; | ||
arguments[0] = this; | ||
callback.apply(null, arguments); | ||
return this; | ||
} | ||
function selection_nodes() { | ||
var nodes = new Array(this.size()), i = -1; | ||
this.each(function() { nodes[++i] = this; }); | ||
return nodes; | ||
} | ||
function selection_node() { | ||
for (var groups = this._nodes, j = 0, m = groups.length; j < m; ++j) { | ||
for (var group = groups[j], i = 0, n = group.length; i < n; ++i) { | ||
var node = group[i]; | ||
if (node) return node; | ||
} | ||
} | ||
return null; | ||
} | ||
function selection_size() { | ||
var size = 0; | ||
this.each(function() { ++size; }); | ||
return size; | ||
} | ||
function selection_empty() { | ||
return !this.node(); | ||
} | ||
function selection_each(callback) { | ||
for (var groups = this._nodes, j = 0, m = groups.length; j < m; ++j) { | ||
for (var group = groups[j], i = 0, n = group.length, node; i < n; ++i) { | ||
if (node = group[i]) callback.call(node, node.__data__, i, group); | ||
} | ||
} | ||
return this; | ||
} | ||
var namespaces = { | ||
@@ -173,123 +474,117 @@ svg: "http://www.w3.org/2000/svg", | ||
function selector(selector) { | ||
function attrRemove(name) { | ||
return function() { | ||
return this.querySelector(selector); | ||
this.removeAttribute(name); | ||
}; | ||
} | ||
function creatorInherit(name) { | ||
function attrRemoveNS(fullname) { | ||
return function() { | ||
var document = this.ownerDocument, | ||
uri = this.namespaceURI; | ||
return uri && uri !== document.documentElement.namespaceURI | ||
? document.createElementNS(uri, name) | ||
: document.createElement(name); | ||
this.removeAttributeNS(fullname.space, fullname.local); | ||
}; | ||
} | ||
function creatorFixed(fullname) { | ||
function attrConstant(name, value) { | ||
return function() { | ||
return this.ownerDocument.createElementNS(fullname.space, fullname.local); | ||
this.setAttribute(name, value); | ||
}; | ||
} | ||
function creator(name) { | ||
var fullname = namespace(name); | ||
return (fullname.local | ||
? creatorFixed | ||
: creatorInherit)(fullname); | ||
function attrConstantNS(fullname, value) { | ||
return function() { | ||
this.setAttributeNS(fullname.space, fullname.local, value); | ||
}; | ||
} | ||
function append(create) { | ||
function attrFunction(name, value) { | ||
return function() { | ||
return this.appendChild(create.apply(this, arguments)); | ||
var v = value.apply(this, arguments); | ||
if (v == null) this.removeAttribute(name); | ||
else this.setAttribute(name, v); | ||
}; | ||
} | ||
function insert(create, select) { | ||
function attrFunctionNS(fullname, value) { | ||
return function() { | ||
return this.insertBefore(create.apply(this, arguments), select.apply(this, arguments) || null); | ||
var v = value.apply(this, arguments); | ||
if (v == null) this.removeAttributeNS(fullname.space, fullname.local); | ||
else this.setAttributeNS(fullname.space, fullname.local, v); | ||
}; | ||
} | ||
function constantNull() { | ||
return null; | ||
} | ||
function selection_attr(name, value) { | ||
var fullname = namespace(name); | ||
function selection_append(name, before) { | ||
var create = typeof name === "function" ? name : creator(name); | ||
return this.select(arguments.length < 2 | ||
? append(create) | ||
: insert(create, before == null | ||
? constantNull : typeof before === "function" | ||
? before | ||
: selector(before))); | ||
} | ||
if (arguments.length < 2) { | ||
var node = this.node(); | ||
return fullname.local | ||
? node.getAttributeNS(fullname.space, fullname.local) | ||
: node.getAttribute(fullname); | ||
} | ||
function lower() { | ||
this.parentNode.insertBefore(this, this.parentNode.firstChild); | ||
return this.each((value == null | ||
? (fullname.local ? attrRemoveNS : attrRemove) : (typeof value === "function" | ||
? (fullname.local ? attrFunctionNS : attrFunction) | ||
: (fullname.local ? attrConstantNS : attrConstant)))(fullname, value)); | ||
} | ||
function selection_lower() { | ||
return this.each(lower); | ||
function styleRemove(name) { | ||
return function() { | ||
this.style.removeProperty(name); | ||
}; | ||
} | ||
function raise() { | ||
this.parentNode.appendChild(this); | ||
} | ||
function selection_raise() { | ||
return this.each(raise); | ||
} | ||
function htmlRemove() { | ||
this.innerHTML = ""; | ||
} | ||
function htmlConstant(value) { | ||
function styleConstant(name, value, priority) { | ||
return function() { | ||
this.innerHTML = value; | ||
this.style.setProperty(name, value, priority); | ||
}; | ||
} | ||
function htmlFunction(value) { | ||
function styleFunction(name, value, priority) { | ||
return function() { | ||
var v = value.apply(this, arguments); | ||
this.innerHTML = v == null ? "" : v; | ||
if (v == null) this.style.removeProperty(name); | ||
else this.style.setProperty(name, v, priority); | ||
}; | ||
} | ||
function selection_html(value) { | ||
return arguments.length | ||
? this.each(value == null | ||
? htmlRemove : (typeof value === "function" | ||
? htmlFunction | ||
: htmlConstant)(value)) | ||
: this.node().innerHTML; | ||
function selection_style(name, value, priority) { | ||
var node; | ||
return arguments.length > 1 | ||
? this.each((value == null | ||
? styleRemove : typeof value === "function" | ||
? styleFunction | ||
: styleConstant)(name, value, priority == null ? "" : priority)) | ||
: defaultView(node = this.node()) | ||
.getComputedStyle(node, null) | ||
.getPropertyValue(name); | ||
} | ||
function textRemove() { | ||
this.textContent = ""; | ||
function propertyRemove(name) { | ||
return function() { | ||
delete this[name]; | ||
}; | ||
} | ||
function textConstant(value) { | ||
function propertyConstant(name, value) { | ||
return function() { | ||
this.textContent = value; | ||
this[name] = value; | ||
}; | ||
} | ||
function textFunction(value) { | ||
function propertyFunction(name, value) { | ||
return function() { | ||
var v = value.apply(this, arguments); | ||
this.textContent = v == null ? "" : v; | ||
if (v == null) delete this[name]; | ||
else this[name] = v; | ||
}; | ||
} | ||
function selection_text(value) { | ||
return arguments.length | ||
? this.each(value == null | ||
? textRemove : (typeof value === "function" | ||
? textFunction | ||
: textConstant)(value)) | ||
: this.node().textContent; | ||
function selection_property(name, value) { | ||
return arguments.length > 1 | ||
? this.each((value == null | ||
? propertyRemove : typeof value === "function" | ||
? propertyFunction | ||
: propertyConstant)(name, value)) | ||
: this.node()[name]; | ||
} | ||
@@ -373,462 +668,167 @@ | ||
function propertyRemove(name) { | ||
return function() { | ||
delete this[name]; | ||
}; | ||
function textRemove() { | ||
this.textContent = ""; | ||
} | ||
function propertyConstant(name, value) { | ||
function textConstant(value) { | ||
return function() { | ||
this[name] = value; | ||
this.textContent = value; | ||
}; | ||
} | ||
function propertyFunction(name, value) { | ||
function textFunction(value) { | ||
return function() { | ||
var v = value.apply(this, arguments); | ||
if (v == null) delete this[name]; | ||
else this[name] = v; | ||
this.textContent = v == null ? "" : v; | ||
}; | ||
} | ||
function selection_property(name, value) { | ||
return arguments.length > 1 | ||
? this.each((value == null | ||
? propertyRemove : typeof value === "function" | ||
? propertyFunction | ||
: propertyConstant)(name, value)) | ||
: this.node()[name]; | ||
function selection_text(value) { | ||
return arguments.length | ||
? this.each(value == null | ||
? textRemove : (typeof value === "function" | ||
? textFunction | ||
: textConstant)(value)) | ||
: this.node().textContent; | ||
} | ||
function styleRemove(name) { | ||
return function() { | ||
this.style.removeProperty(name); | ||
}; | ||
function htmlRemove() { | ||
this.innerHTML = ""; | ||
} | ||
function styleConstant(name, value, priority) { | ||
function htmlConstant(value) { | ||
return function() { | ||
this.style.setProperty(name, value, priority); | ||
this.innerHTML = value; | ||
}; | ||
} | ||
function styleFunction(name, value, priority) { | ||
function htmlFunction(value) { | ||
return function() { | ||
var v = value.apply(this, arguments); | ||
if (v == null) this.style.removeProperty(name); | ||
else this.style.setProperty(name, v, priority); | ||
this.innerHTML = v == null ? "" : v; | ||
}; | ||
} | ||
function selection_style(name, value, priority) { | ||
var node; | ||
return arguments.length > 1 | ||
? this.each((value == null | ||
? styleRemove : typeof value === "function" | ||
? styleFunction | ||
: styleConstant)(name, value, priority == null ? "" : priority)) | ||
: defaultView(node = this.node()) | ||
.getComputedStyle(node, null) | ||
.getPropertyValue(name); | ||
function selection_html(value) { | ||
return arguments.length | ||
? this.each(value == null | ||
? htmlRemove : (typeof value === "function" | ||
? htmlFunction | ||
: htmlConstant)(value)) | ||
: this.node().innerHTML; | ||
} | ||
function attrRemove(name) { | ||
return function() { | ||
this.removeAttribute(name); | ||
}; | ||
function raise() { | ||
this.parentNode.appendChild(this); | ||
} | ||
function attrRemoveNS(fullname) { | ||
return function() { | ||
this.removeAttributeNS(fullname.space, fullname.local); | ||
}; | ||
function selection_raise() { | ||
return this.each(raise); | ||
} | ||
function attrConstant(name, value) { | ||
return function() { | ||
this.setAttribute(name, value); | ||
}; | ||
function lower() { | ||
this.parentNode.insertBefore(this, this.parentNode.firstChild); | ||
} | ||
function attrConstantNS(fullname, value) { | ||
return function() { | ||
this.setAttributeNS(fullname.space, fullname.local, value); | ||
}; | ||
function selection_lower() { | ||
return this.each(lower); | ||
} | ||
function attrFunction(name, value) { | ||
function creatorInherit(name) { | ||
return function() { | ||
var v = value.apply(this, arguments); | ||
if (v == null) this.removeAttribute(name); | ||
else this.setAttribute(name, v); | ||
var document = this.ownerDocument, | ||
uri = this.namespaceURI; | ||
return uri && uri !== document.documentElement.namespaceURI | ||
? document.createElementNS(uri, name) | ||
: document.createElement(name); | ||
}; | ||
} | ||
function attrFunctionNS(fullname, value) { | ||
function creatorFixed(fullname) { | ||
return function() { | ||
var v = value.apply(this, arguments); | ||
if (v == null) this.removeAttributeNS(fullname.space, fullname.local); | ||
else this.setAttributeNS(fullname.space, fullname.local, v); | ||
return this.ownerDocument.createElementNS(fullname.space, fullname.local); | ||
}; | ||
} | ||
function selection_attr(name, value) { | ||
function creator(name) { | ||
var fullname = namespace(name); | ||
if (arguments.length < 2) { | ||
var node = this.node(); | ||
return fullname.local | ||
? node.getAttributeNS(fullname.space, fullname.local) | ||
: node.getAttribute(fullname); | ||
} | ||
return this.each((value == null | ||
? (fullname.local ? attrRemoveNS : attrRemove) : (typeof value === "function" | ||
? (fullname.local ? attrFunctionNS : attrFunction) | ||
: (fullname.local ? attrConstantNS : attrConstant)))(fullname, value)); | ||
return (fullname.local | ||
? creatorFixed | ||
: creatorInherit)(fullname); | ||
} | ||
function selection_each(callback) { | ||
for (var groups = this._nodes, j = 0, m = groups.length; j < m; ++j) { | ||
for (var group = groups[j], i = 0, n = group.length, node; i < n; ++i) { | ||
if (node = group[i]) callback.call(node, node.__data__, i, group); | ||
} | ||
} | ||
return this; | ||
function append(create) { | ||
return function() { | ||
return this.appendChild(create.apply(this, arguments)); | ||
}; | ||
} | ||
function selection_empty() { | ||
return !this.node(); | ||
function insert(create, select) { | ||
return function() { | ||
return this.insertBefore(create.apply(this, arguments), select.apply(this, arguments) || null); | ||
}; | ||
} | ||
function selection_size() { | ||
var size = 0; | ||
this.each(function() { ++size; }); | ||
return size; | ||
} | ||
function selection_node() { | ||
for (var groups = this._nodes, j = 0, m = groups.length; j < m; ++j) { | ||
for (var group = groups[j], i = 0, n = group.length; i < n; ++i) { | ||
var node = group[i]; | ||
if (node) return node; | ||
} | ||
} | ||
function constantNull() { | ||
return null; | ||
} | ||
function selection_nodes() { | ||
var nodes = new Array(this.size()), i = -1; | ||
this.each(function() { nodes[++i] = this; }); | ||
return nodes; | ||
function selection_append(name, before) { | ||
var create = typeof name === "function" ? name : creator(name); | ||
return this.select(arguments.length < 2 | ||
? append(create) | ||
: insert(create, before == null | ||
? constantNull : typeof before === "function" | ||
? before | ||
: selector(before))); | ||
} | ||
function selection_call() { | ||
var callback = arguments[0]; | ||
arguments[0] = this; | ||
callback.apply(null, arguments); | ||
return this; | ||
function remove() { | ||
var parent = this.parentNode; | ||
if (parent) parent.removeChild(this); | ||
} | ||
function arrayify(selection) { | ||
for (var groups = selection._nodes, j = 0, m = groups.length; j < m; ++j) { | ||
if (!Array.isArray(group = groups[j])) { | ||
for (var n = group.length, array = groups[j] = new Array(n), group, i = 0; i < n; ++i) { | ||
array[i] = group[i]; | ||
} | ||
} | ||
} | ||
return groups; | ||
function selection_remove() { | ||
return this.each(remove); | ||
} | ||
function selection_sort(compare) { | ||
if (!compare) compare = ascending; | ||
function compareNode(a, b) { | ||
return a && b ? compare(a.__data__, b.__data__) : !a - !b; | ||
} | ||
for (var groups = arrayify(this), j = 0, m = groups.length; j < m; ++j) { | ||
groups[j].sort(compareNode); | ||
} | ||
return this.order(); | ||
function selection_datum(value) { | ||
return arguments.length | ||
? this.property("__data__", value) | ||
: this.node().__data__; | ||
} | ||
function ascending(a, b) { | ||
return a < b ? -1 : a > b ? 1 : a >= b ? 0 : NaN; | ||
} | ||
function dispatchEvent(node, type, params) { | ||
var window = defaultView(node), | ||
event = window.CustomEvent; | ||
function selection_order() { | ||
for (var groups = this._nodes, j = -1, m = groups.length; ++j < m;) { | ||
for (var group = groups[j], i = group.length - 1, next = group[i], node; --i >= 0;) { | ||
if (node = group[i]) { | ||
if (next && next !== node.nextSibling) next.parentNode.insertBefore(node, next); | ||
next = node; | ||
} | ||
} | ||
if (event) { | ||
event = new event(type, params); | ||
} else { | ||
event = window.document.createEvent("Event"); | ||
if (params) event.initEvent(type, params.bubbles, params.cancelable), event.detail = params.detail; | ||
else event.initEvent(type, false, false); | ||
} | ||
return this; | ||
node.dispatchEvent(event); | ||
} | ||
function sparse(update) { | ||
return new Array(update.length); | ||
} | ||
function selection_exit() { | ||
var exit = this._exit; | ||
if (exit) return this._exit = null, exit; | ||
return new Selection(this._nodes.map(sparse), this._parents); | ||
} | ||
function selection_enter() { | ||
var enter = this._enter; | ||
if (enter) return this._enter = null, enter; | ||
enter = new Selection(this._nodes.map(sparse), this._parents); | ||
enter._update = this; | ||
return enter; | ||
} | ||
function constant(x) { | ||
function dispatchConstant(type, params) { | ||
return function() { | ||
return x; | ||
return dispatchEvent(this, type, params); | ||
}; | ||
} | ||
var keyPrefix = "$"; // Protect against keys like “__proto__”. | ||
function bindIndex(parent, update, enter, exit, data) { | ||
var i = 0, | ||
node, | ||
nodeLength = update.length, | ||
dataLength = data.length, | ||
minLength = Math.min(nodeLength, dataLength); | ||
// Clear the enter and exit arrays, and then initialize to the new length. | ||
enter.length = 0, enter.length = dataLength; | ||
exit.length = 0, exit.length = nodeLength; | ||
for (; i < minLength; ++i) { | ||
if (node = update[i]) { | ||
node.__data__ = data[i]; | ||
} else { | ||
enter[i] = new EnterNode(parent, data[i]); | ||
} | ||
} | ||
// Note: we don’t need to delete update[i] here because this loop only | ||
// runs when the data length is greater than the node length. | ||
for (; i < dataLength; ++i) { | ||
enter[i] = new EnterNode(parent, data[i]); | ||
} | ||
// Note: and, we don’t need to delete update[i] here because immediately | ||
// following this loop we set the update length to data length. | ||
for (; i < nodeLength; ++i) { | ||
if (node = update[i]) { | ||
exit[i] = update[i]; | ||
} | ||
} | ||
update.length = dataLength; | ||
} | ||
function bindKey(parent, update, enter, exit, data, key) { | ||
var i, | ||
node, | ||
dataLength = data.length, | ||
nodeLength = update.length, | ||
nodeByKeyValue = {}, | ||
keyValues = new Array(nodeLength), | ||
keyValue; | ||
// Clear the enter and exit arrays, and then initialize to the new length. | ||
enter.length = 0, enter.length = dataLength; | ||
exit.length = 0, exit.length = nodeLength; | ||
// Compute the keys for each node. | ||
for (i = 0; i < nodeLength; ++i) { | ||
if (node = update[i]) { | ||
keyValues[i] = keyValue = keyPrefix + key.call(node, node.__data__, i, update); | ||
// Is this a duplicate of a key we’ve previously seen? | ||
// If so, this node is moved to the exit selection. | ||
if (nodeByKeyValue[keyValue]) { | ||
exit[i] = node; | ||
} | ||
// Otherwise, record the mapping from key to node. | ||
else { | ||
nodeByKeyValue[keyValue] = node; | ||
} | ||
} | ||
} | ||
// Now clear the update array and initialize to the new length. | ||
update.length = 0, update.length = dataLength; | ||
// Compute the keys for each datum. | ||
for (i = 0; i < dataLength; ++i) { | ||
keyValue = keyPrefix + key.call(parent, data[i], i, data); | ||
// Is there a node associated with this key? | ||
// If not, this datum is added to the enter selection. | ||
if (!(node = nodeByKeyValue[keyValue])) { | ||
enter[i] = new EnterNode(parent, data[i]); | ||
} | ||
// Did we already bind a node using this key? (Or is a duplicate?) | ||
// If unique, the node and datum are joined in the update selection. | ||
// Otherwise, the datum is ignored, neither entering nor exiting. | ||
else if (node !== true) { | ||
update[i] = node; | ||
node.__data__ = data[i]; | ||
} | ||
// Record that we consumed this key, either to enter or update. | ||
nodeByKeyValue[keyValue] = true; | ||
} | ||
// Take any remaining nodes that were not bound to data, | ||
// and place them in the exit selection. | ||
for (i = 0; i < nodeLength; ++i) { | ||
if ((node = nodeByKeyValue[keyValues[i]]) !== true) { | ||
exit[i] = node; | ||
} | ||
} | ||
} | ||
function selection_data(value, key) { | ||
if (!value) { | ||
var data = new Array(this.size()), i = -1; | ||
this.each(function(d) { data[++i] = d; }); | ||
return data; | ||
} | ||
var bind = key ? bindKey : bindIndex, | ||
parents = this._parents, | ||
update = arrayify(this), | ||
enter = (this._enter = this.enter())._nodes, | ||
exit = (this._exit = this.exit())._nodes; | ||
if (typeof value !== "function") value = constant(value); | ||
for (var m = update.length, j = 0; j < m; ++j) { | ||
var group = update[j], | ||
parent = parents[j]; | ||
bind(parent, group, enter[j], exit[j], value.call(parent, parent && parent.__data__, j, parents), key); | ||
// Now connect the enter nodes to their following update node, such that | ||
// appendChild can insert the materialized enter node before this node, | ||
// rather than at the end of the parent node. | ||
for (var n = group.length, i0 = 0, i1 = 0, previous, next; i0 < n; ++i0) { | ||
if (previous = enter[j][i0]) { | ||
if (i0 >= i1) i1 = i0 + 1; | ||
while (!(next = group[i1]) && ++i1 < n); | ||
previous._next = next || null; | ||
} | ||
} | ||
} | ||
return this; | ||
} | ||
function EnterNode(parent, datum) { | ||
this.ownerDocument = parent.ownerDocument; | ||
this.namespaceURI = parent.namespaceURI; | ||
this._next = null; | ||
this._parent = parent; | ||
this.__data__ = datum; | ||
} | ||
EnterNode.prototype = { | ||
appendChild: function(child) { return this._parent.insertBefore(child, this._next); }, | ||
insertBefore: function(child, next) { return this._parent.insertBefore(child, next); }, | ||
querySelector: function(selector) { return this._parent.querySelector(selector); }, | ||
querySelectorAll: function(selector) { return this._parent.querySelectorAll(selector); } | ||
}; | ||
var matcher = function(selector) { | ||
function dispatchFunction(type, params) { | ||
return function() { | ||
return this.matches(selector); | ||
return dispatchEvent(this, type, params.apply(this, arguments)); | ||
}; | ||
}; | ||
if (typeof document !== "undefined") { | ||
var element$1 = document.documentElement; | ||
if (!element$1.matches) { | ||
var vendorMatches = element$1.webkitMatchesSelector | ||
|| element$1.msMatchesSelector | ||
|| element$1.mozMatchesSelector | ||
|| element$1.oMatchesSelector; | ||
matcher = function(selector) { | ||
return function() { | ||
return vendorMatches.call(this, selector); | ||
}; | ||
}; | ||
} | ||
} | ||
var matcher$1 = matcher; | ||
function selection_filter(match) { | ||
if (typeof match !== "function") match = matcher$1(match); | ||
for (var groups = this._nodes, m = groups.length, subgroups = new Array(m), j = 0; j < m; ++j) { | ||
for (var group = groups[j], n = group.length, subgroup = subgroups[j] = [], node, i = 0; i < n; ++i) { | ||
if ((node = group[i]) && match.call(node, node.__data__, i, group)) { | ||
subgroup.push(node); | ||
} | ||
} | ||
} | ||
return new Selection(subgroups, this._parents); | ||
function selection_dispatch(type, params) { | ||
return this.each((typeof params === "function" | ||
? dispatchFunction | ||
: dispatchConstant)(type, params)); | ||
} | ||
function selectorAll(selector) { | ||
return function() { | ||
return this.querySelectorAll(selector); | ||
}; | ||
} | ||
function selection_selectAll(select) { | ||
if (typeof select !== "function") select = selectorAll(select); | ||
for (var groups = this._nodes, m = groups.length, subgroups = [], parents = [], j = 0; j < m; ++j) { | ||
for (var group = groups[j], n = group.length, node, i = 0; i < n; ++i) { | ||
if (node = group[i]) { | ||
subgroups.push(select.call(node, node.__data__, i, group)); | ||
parents.push(node); | ||
} | ||
} | ||
} | ||
return new Selection(subgroups, parents); | ||
} | ||
function selection_select(select) { | ||
if (typeof select !== "function") select = selector(select); | ||
for (var groups = this._nodes, update = this._update, m = groups.length, subgroups = new Array(m), j = 0; j < m; ++j) { | ||
for (var group = groups[j], n = group.length, subgroup = subgroups[j] = new Array(n), node, subnode, i = 0; i < n; ++i) { | ||
if ((node = group[i]) && (subnode = select.call(node, node.__data__, i, group))) { | ||
if ("__data__" in node) subnode.__data__ = node.__data__; | ||
if (update) update._nodes[j][i] = subnode; | ||
subgroup[i] = subnode; | ||
} | ||
} | ||
} | ||
return new Selection(subgroups, this._parents); | ||
} | ||
var root = [null]; | ||
@@ -944,3 +944,3 @@ | ||
var version = "0.6.3"; | ||
var version = "0.6.5"; | ||
@@ -947,0 +947,0 @@ exports.version = version; |
@@ -1,1 +0,1 @@ | ||
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define("d3-selection",["exports"],n):n(t.d3_selection={})}(this,function(t){"use strict";function n(t){return t.replace(zt,"\\$&")}function e(){}function r(n,e,r){return function(i){var o=t.event;t.event=i;try{n.call(this,this.__data__,e,r)}finally{t.event=o}}}function i(t){return function(n){var e=n.relatedTarget;e&&(e===this||8&e.compareDocumentPosition(this))||t(n)}}function o(t,n){return function(){var e=this[t];e&&(this.removeEventListener(n,e,e._capture),delete this[t])}}function u(t){var e=new RegExp("^__on([^.]+)"+n(t)+"$");return function(){for(var t in this){var n=t.match(e);if(n){var r=this[t];this.removeEventListener(n[1],r,r._capture),delete this[t]}}}}function s(t,n,e,o,u){return function(s,a,c){var l=this[n];l&&this.removeEventListener(e,l,l._capture),l=r(o,a,c),t&&(l=i(l)),l._listener=o,this.addEventListener(e,this[n]=l,l._capture=u)}}function a(t,n,r){var i,a,c=t+"",l="__on"+c;return arguments.length<2?(i=this.node()[l])&&i._listener:((i=c.indexOf("."))>0&&(c=c.slice(0,i)),(a=Ht.hasOwnProperty(c))&&(c=Ht[c]),this.each(n?i?s(a,l,c,n,null==r?!1:r):e:i?o(l,c):u(c)))}function c(){for(var n,e=t.event;n=e.sourceEvent;)e=n;return e}function l(t){return t&&(t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView)}function h(t,n,e){var r=l(t),i=r.CustomEvent;i?i=new i(n,e):(i=r.document.createEvent("Event"),e?(i.initEvent(n,e.bubbles,e.cancelable),i.detail=e.detail):i.initEvent(n,!1,!1)),t.dispatchEvent(i)}function f(t,n){return function(){return h(this,t,n)}}function p(t,n){return function(){return h(this,t,n.apply(this,arguments))}}function d(t,n){return this.each(("function"==typeof n?p:f)(t,n))}function _(t){return arguments.length?this.property("__data__",t):this.node().__data__}function m(){var t=this.parentNode;t&&t.removeChild(this)}function v(){return this.each(m)}function g(t){var n=t+="",e=n.indexOf(":");return e>=0&&"xmlns"!==(n=t.slice(0,e))&&(t=t.slice(e+1)),Ut.hasOwnProperty(n)?{space:Ut[n],local:t}:t}function y(t){return function(){return this.querySelector(t)}}function w(t){return function(){var n=this.ownerDocument,e=this.namespaceURI;return e&&e!==n.documentElement.namespaceURI?n.createElementNS(e,t):n.createElement(t)}}function x(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function A(t){var n=g(t);return(n.local?x:w)(n)}function S(t){return function(){return this.appendChild(t.apply(this,arguments))}}function b(t,n){return function(){return this.insertBefore(t.apply(this,arguments),n.apply(this,arguments)||null)}}function E(){return null}function C(t,n){var e="function"==typeof t?t:A(t);return this.select(arguments.length<2?S(e):b(e,null==n?E:"function"==typeof n?n:y(n)))}function N(){this.parentNode.insertBefore(this,this.parentNode.firstChild)}function M(){return this.each(N)}function T(){this.parentNode.appendChild(this)}function L(){return this.each(T)}function P(){this.innerHTML=""}function q(t){return function(){this.innerHTML=t}}function B(t){return function(){var n=t.apply(this,arguments);this.innerHTML=null==n?"":n}}function D(t){return arguments.length?this.each(null==t?P:("function"==typeof t?B:q)(t)):this.node().innerHTML}function O(){this.textContent=""}function R(t){return function(){this.textContent=t}}function V(t){return function(){var n=t.apply(this,arguments);this.textContent=null==n?"":n}}function X(t){return arguments.length?this.each(null==t?O:("function"==typeof t?V:R)(t)):this.node().textContent}function z(t){return t.trim().split(/^|\s+/)}function H(t){return t.classList||new I(t)}function I(t){this._node=t,this._names=z(t.getAttribute("class")||"")}function U(t,n){for(var e=H(t),r=-1,i=n.length;++r<i;)e.add(n[r])}function Y(t,n){for(var e=H(t),r=-1,i=n.length;++r<i;)e.remove(n[r])}function $(t){return function(){U(this,t)}}function j(t){return function(){Y(this,t)}}function k(t,n){return function(){(n.apply(this,arguments)?U:Y)(this,t)}}function G(t,n){var e=z(t+"");if(arguments.length<2){for(var r=H(this.node()),i=-1,o=e.length;++i<o;)if(!r.contains(e[i]))return!1;return!0}return this.each(("function"==typeof n?k:n?$:j)(e,n))}function K(t){return function(){delete this[t]}}function W(t,n){return function(){this[t]=n}}function F(t,n){return function(){var e=n.apply(this,arguments);null==e?delete this[t]:this[t]=e}}function J(t,n){return arguments.length>1?this.each((null==n?K:"function"==typeof n?F:W)(t,n)):this.node()[t]}function Q(t){return function(){this.style.removeProperty(t)}}function Z(t,n,e){return function(){this.style.setProperty(t,n,e)}}function tt(t,n,e){return function(){var r=n.apply(this,arguments);null==r?this.style.removeProperty(t):this.style.setProperty(t,r,e)}}function nt(t,n,e){var r;return arguments.length>1?this.each((null==n?Q:"function"==typeof n?tt:Z)(t,n,null==e?"":e)):l(r=this.node()).getComputedStyle(r,null).getPropertyValue(t)}function et(t){return function(){this.removeAttribute(t)}}function rt(t){return function(){this.removeAttributeNS(t.space,t.local)}}function it(t,n){return function(){this.setAttribute(t,n)}}function ot(t,n){return function(){this.setAttributeNS(t.space,t.local,n)}}function ut(t,n){return function(){var e=n.apply(this,arguments);null==e?this.removeAttribute(t):this.setAttribute(t,e)}}function st(t,n){return function(){var e=n.apply(this,arguments);null==e?this.removeAttributeNS(t.space,t.local):this.setAttributeNS(t.space,t.local,e)}}function at(t,n){var e=g(t);if(arguments.length<2){var r=this.node();return e.local?r.getAttributeNS(e.space,e.local):r.getAttribute(e)}return this.each((null==n?e.local?rt:et:"function"==typeof n?e.local?st:ut:e.local?ot:it)(e,n))}function ct(t){for(var n=this._nodes,e=0,r=n.length;r>e;++e)for(var i,o=n[e],u=0,s=o.length;s>u;++u)(i=o[u])&&t.call(i,i.__data__,u,o);return this}function lt(){return!this.node()}function ht(){var t=0;return this.each(function(){++t}),t}function ft(){for(var t=this._nodes,n=0,e=t.length;e>n;++n)for(var r=t[n],i=0,o=r.length;o>i;++i){var u=r[i];if(u)return u}return null}function pt(){var t=new Array(this.size()),n=-1;return this.each(function(){t[++n]=this}),t}function dt(){var t=arguments[0];return arguments[0]=this,t.apply(null,arguments),this}function _t(t){for(var n=t._nodes,e=0,r=n.length;r>e;++e)if(!Array.isArray(i=n[e]))for(var i,o=i.length,u=n[e]=new Array(o),s=0;o>s;++s)u[s]=i[s];return n}function mt(t){function n(n,e){return n&&e?t(n.__data__,e.__data__):!n-!e}t||(t=vt);for(var e=_t(this),r=0,i=e.length;i>r;++r)e[r].sort(n);return this.order()}function vt(t,n){return n>t?-1:t>n?1:t>=n?0:NaN}function gt(){for(var t=this._nodes,n=-1,e=t.length;++n<e;)for(var r,i=t[n],o=i.length-1,u=i[o];--o>=0;)(r=i[o])&&(u&&u!==r.nextSibling&&u.parentNode.insertBefore(r,u),u=r);return this}function yt(t){return new Array(t.length)}function wt(){var t=this._exit;return t?(this._exit=null,t):new Pt(this._nodes.map(yt),this._parents)}function xt(){var t=this._enter;return t?(this._enter=null,t):(t=new Pt(this._nodes.map(yt),this._parents),t._update=this,t)}function At(t){return function(){return t}}function St(t,n,e,r,i){var o,u=0,s=n.length,a=i.length,c=Math.min(s,a);for(e.length=0,e.length=a,r.length=0,r.length=s;c>u;++u)(o=n[u])?o.__data__=i[u]:e[u]=new Ct(t,i[u]);for(;a>u;++u)e[u]=new Ct(t,i[u]);for(;s>u;++u)(o=n[u])&&(r[u]=n[u]);n.length=a}function bt(t,n,e,r,i,o){var u,s,a,c=i.length,l=n.length,h={},f=new Array(l);for(e.length=0,e.length=c,r.length=0,r.length=l,u=0;l>u;++u)(s=n[u])&&(f[u]=a=Yt+o.call(s,s.__data__,u,n),h[a]?r[u]=s:h[a]=s);for(n.length=0,n.length=c,u=0;c>u;++u)a=Yt+o.call(t,i[u],u,i),(s=h[a])?s!==!0&&(n[u]=s,s.__data__=i[u]):e[u]=new Ct(t,i[u]),h[a]=!0;for(u=0;l>u;++u)(s=h[f[u]])!==!0&&(r[u]=s)}function Et(t,n){if(!t){var e=new Array(this.size()),r=-1;return this.each(function(t){e[++r]=t}),e}var i=n?bt:St,o=this._parents,u=_t(this),s=(this._enter=this.enter())._nodes,a=(this._exit=this.exit())._nodes;"function"!=typeof t&&(t=At(t));for(var c=u.length,l=0;c>l;++l){var h=u[l],f=o[l];i(f,h,s[l],a[l],t.call(f,f&&f.__data__,l,o),n);for(var p,d,_=h.length,m=0,v=0;_>m;++m)if(p=s[l][m]){for(m>=v&&(v=m+1);!(d=h[v])&&++v<_;);p._next=d||null}}return this}function Ct(t,n){this.ownerDocument=t.ownerDocument,this.namespaceURI=t.namespaceURI,this._next=null,this._parent=t,this.__data__=n}function Nt(t){"function"!=typeof t&&(t=Gt(t));for(var n=this._nodes,e=n.length,r=new Array(e),i=0;e>i;++i)for(var o,u=n[i],s=u.length,a=r[i]=[],c=0;s>c;++c)(o=u[c])&&t.call(o,o.__data__,c,u)&&a.push(o);return new Pt(r,this._parents)}function Mt(t){return function(){return this.querySelectorAll(t)}}function Tt(t){"function"!=typeof t&&(t=Mt(t));for(var n=this._nodes,e=n.length,r=[],i=[],o=0;e>o;++o)for(var u,s=n[o],a=s.length,c=0;a>c;++c)(u=s[c])&&(r.push(t.call(u,u.__data__,c,s)),i.push(u));return new Pt(r,i)}function Lt(t){"function"!=typeof t&&(t=y(t));for(var n=this._nodes,e=this._update,r=n.length,i=new Array(r),o=0;r>o;++o)for(var u,s,a=n[o],c=a.length,l=i[o]=new Array(c),h=0;c>h;++h)(u=a[h])&&(s=t.call(u,u.__data__,h,a))&&("__data__"in u&&(s.__data__=u.__data__),e&&(e._nodes[o][h]=s),l[h]=s);return new Pt(i,this._parents)}function Pt(t,n){this._nodes=t,this._parents=n}function qt(){return new Pt([[document.documentElement]],Kt)}function Bt(t){return"string"==typeof t?new Pt([[document.querySelector(t)]],[document.documentElement]):new Pt([[t]],Kt)}function Dt(t,n){var e=t.ownerSVGElement||t;if(e.createSVGPoint){var r=e.createSVGPoint();if(0>Wt){var i=l(t);if(i.scrollX||i.scrollY){e=Bt(i.document.body).append("svg").style({position:"absolute",top:0,left:0,margin:0,padding:0,border:"none"},"important");var o=e.node().getScreenCTM();Wt=!(o.f||o.e),e.remove()}}return Wt?(r.x=n.pageX,r.y=n.pageY):(r.x=n.clientX,r.y=n.clientY),r=r.matrixTransform(t.getScreenCTM().inverse()),[r.x,r.y]}var u=t.getBoundingClientRect();return[n.clientX-u.left-t.clientLeft,n.clientY-u.top-t.clientTop]}function Ot(t,n){return null==n&&(n=c()),n.changedTouches&&(n=n.changedTouches[0]),Dt(t,n)}function Rt(t){return"string"==typeof t?new Pt([document.querySelectorAll(t)],[document.documentElement]):new Pt([t],Kt)}function Vt(t,n,e){arguments.length<3&&(e=n,n=c().changedTouches);for(var r,i=0,o=n?n.length:0;o>i;++i)if((r=n[i]).identifier===e)return Dt(t,r);return null}function Xt(t,n){null==n&&(n=c().touches);for(var e=0,r=n?n.length:0,i=new Array(r);r>e;++e)i[e]=Dt(t,n[e]);return i}var zt=/[\\\^\$\*\+\?\|\[\]\(\)\.\{\}]/g,Ht={};if(t.event=null,"undefined"!=typeof document){var It=document.documentElement;"onmouseenter"in It||(Ht={mouseenter:"mouseover",mouseleave:"mouseout"})}var Ut={svg:"http://www.w3.org/2000/svg",xhtml:"http://www.w3.org/1999/xhtml",xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};I.prototype={add:function(t){var n=this._names.indexOf(t);0>n&&(this._names.push(t),this._node.setAttribute("class",this._names.join(" ")))},remove:function(t){var n=this._names.indexOf(t);n>=0&&(this._names.splice(n,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}};var Yt="$";Ct.prototype={appendChild:function(t){return this._parent.insertBefore(t,this._next)},insertBefore:function(t,n){return this._parent.insertBefore(t,n)},querySelector:function(t){return this._parent.querySelector(t)},querySelectorAll:function(t){return this._parent.querySelectorAll(t)}};var $t=function(t){return function(){return this.matches(t)}};if("undefined"!=typeof document){var jt=document.documentElement;if(!jt.matches){var kt=jt.webkitMatchesSelector||jt.msMatchesSelector||jt.mozMatchesSelector||jt.oMatchesSelector;$t=function(t){return function(){return kt.call(this,t)}}}}var Gt=$t,Kt=[null];Pt.prototype=qt.prototype={select:Lt,selectAll:Tt,filter:Nt,data:Et,enter:xt,exit:wt,order:gt,sort:mt,call:dt,nodes:pt,node:ft,size:ht,empty:lt,each:ct,attr:at,style:nt,property:J,classed:G,text:X,html:D,raise:L,lower:M,append:C,remove:v,datum:_,on:a,dispatch:d};var Wt="undefined"!=typeof navigator&&/WebKit/.test(navigator.userAgent)?-1:0,Ft="0.6.3";t.version=Ft,t.mouse=Ot,t.namespace=g,t.namespaces=Ut,t.select=Bt,t.selectAll=Rt,t.selection=qt,t.touch=Vt,t.touches=Xt}); | ||
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n(t.d3_selection={})}(this,function(t){"use strict";function n(t){return t.replace(zt,"\\$&")}function e(){}function r(n,e,r){return function(i){var o=t.event;t.event=i;try{n.call(this,this.__data__,e,r)}finally{t.event=o}}}function i(t){return function(n){var e=n.relatedTarget;e&&(e===this||8&e.compareDocumentPosition(this))||t(n)}}function o(t,n){return function(){var e=this[t];e&&(this.removeEventListener(n,e,e._capture),delete this[t])}}function u(t){var e=new RegExp("^__on([^.]+)"+n(t)+"$");return function(){for(var t in this){var n=t.match(e);if(n){var r=this[t];this.removeEventListener(n[1],r,r._capture),delete this[t]}}}}function s(t,n,e,o,u){return function(s,a,c){var l=this[n];l&&this.removeEventListener(e,l,l._capture),l=r(o,a,c),t&&(l=i(l)),l._listener=o,this.addEventListener(e,this[n]=l,l._capture=u)}}function a(t,n,r){var i,a,c=t+"",l="__on"+c;return arguments.length<2?(i=this.node()[l])&&i._listener:((i=c.indexOf("."))>0&&(c=c.slice(0,i)),(a=Ht.hasOwnProperty(c))&&(c=Ht[c]),this.each(n?i?s(a,l,c,n,null==r?!1:r):e:i?o(l,c):u(c)))}function c(){for(var n,e=t.event;n=e.sourceEvent;)e=n;return e}function l(t){return t&&(t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView)}function h(t){return function(){return this.querySelector(t)}}function f(t){"function"!=typeof t&&(t=h(t));for(var n=this._nodes,e=this._update,r=n.length,i=new Array(r),o=0;r>o;++o)for(var u,s,a=n[o],c=a.length,l=i[o]=new Array(c),f=0;c>f;++f)(u=a[f])&&(s=t.call(u,u.__data__,f,a))&&("__data__"in u&&(s.__data__=u.__data__),e&&(e._nodes[o][f]=s),l[f]=s);return new Pt(i,this._parents)}function p(t){return function(){return this.querySelectorAll(t)}}function d(t){"function"!=typeof t&&(t=p(t));for(var n=this._nodes,e=n.length,r=[],i=[],o=0;e>o;++o)for(var u,s=n[o],a=s.length,c=0;a>c;++c)(u=s[c])&&(r.push(t.call(u,u.__data__,c,s)),i.push(u));return new Pt(r,i)}function _(t){"function"!=typeof t&&(t=jt(t));for(var n=this._nodes,e=n.length,r=new Array(e),i=0;e>i;++i)for(var o,u=n[i],s=u.length,a=r[i]=[],c=0;s>c;++c)(o=u[c])&&t.call(o,o.__data__,c,u)&&a.push(o);return new Pt(r,this._parents)}function m(t){for(var n=t._nodes,e=0,r=n.length;r>e;++e)if(!Array.isArray(i=n[e]))for(var i,o=i.length,u=n[e]=new Array(o),s=0;o>s;++s)u[s]=i[s];return n}function v(t){return function(){return t}}function g(t,n,e,r,i){var o,u=0,s=n.length,a=i.length,c=Math.min(s,a);for(e.length=0,e.length=a,r.length=0,r.length=s;c>u;++u)(o=n[u])?o.__data__=i[u]:e[u]=new x(t,i[u]);for(;a>u;++u)e[u]=new x(t,i[u]);for(;s>u;++u)(o=n[u])&&(r[u]=n[u]);n.length=a}function y(t,n,e,r,i,o){var u,s,a,c=i.length,l=n.length,h={},f=new Array(l);for(e.length=0,e.length=c,r.length=0,r.length=l,u=0;l>u;++u)(s=n[u])&&(f[u]=a=kt+o.call(s,s.__data__,u,n),h[a]?r[u]=s:h[a]=s);for(n.length=0,n.length=c,u=0;c>u;++u)a=kt+o.call(t,i[u],u,i),(s=h[a])?s!==!0&&(n[u]=s,s.__data__=i[u]):e[u]=new x(t,i[u]),h[a]=!0;for(u=0;l>u;++u)(s=h[f[u]])!==!0&&(r[u]=s)}function w(t,n){if(!t){var e=new Array(this.size()),r=-1;return this.each(function(t){e[++r]=t}),e}var i=n?y:g,o=this._parents,u=m(this),s=(this._enter=this.enter())._nodes,a=(this._exit=this.exit())._nodes;"function"!=typeof t&&(t=v(t));for(var c=u.length,l=0;c>l;++l){var h=u[l],f=o[l];i(f,h,s[l],a[l],t.call(f,f&&f.__data__,l,o),n);for(var p,d,_=h.length,w=0,x=0;_>w;++w)if(p=s[l][w]){for(w>=x&&(x=w+1);!(d=h[x])&&++x<_;);p._next=d||null}}return this}function x(t,n){this.ownerDocument=t.ownerDocument,this.namespaceURI=t.namespaceURI,this._next=null,this._parent=t,this.__data__=n}function A(t){return new Array(t.length)}function S(){var t=this._enter;return t?(this._enter=null,t):(t=new Pt(this._nodes.map(A),this._parents),t._update=this,t)}function b(){var t=this._exit;return t?(this._exit=null,t):new Pt(this._nodes.map(A),this._parents)}function E(){for(var t=this._nodes,n=-1,e=t.length;++n<e;)for(var r,i=t[n],o=i.length-1,u=i[o];--o>=0;)(r=i[o])&&(u&&u!==r.nextSibling&&u.parentNode.insertBefore(r,u),u=r);return this}function C(t){function n(n,e){return n&&e?t(n.__data__,e.__data__):!n-!e}t||(t=N);for(var e=m(this),r=0,i=e.length;i>r;++r)e[r].sort(n);return this.order()}function N(t,n){return n>t?-1:t>n?1:t>=n?0:NaN}function M(){var t=arguments[0];return arguments[0]=this,t.apply(null,arguments),this}function T(){var t=new Array(this.size()),n=-1;return this.each(function(){t[++n]=this}),t}function L(){for(var t=this._nodes,n=0,e=t.length;e>n;++n)for(var r=t[n],i=0,o=r.length;o>i;++i){var u=r[i];if(u)return u}return null}function P(){var t=0;return this.each(function(){++t}),t}function q(){return!this.node()}function B(t){for(var n=this._nodes,e=0,r=n.length;r>e;++e)for(var i,o=n[e],u=0,s=o.length;s>u;++u)(i=o[u])&&t.call(i,i.__data__,u,o);return this}function D(t){var n=t+="",e=n.indexOf(":");return e>=0&&"xmlns"!==(n=t.slice(0,e))&&(t=t.slice(e+1)),Gt.hasOwnProperty(n)?{space:Gt[n],local:t}:t}function O(t){return function(){this.removeAttribute(t)}}function R(t){return function(){this.removeAttributeNS(t.space,t.local)}}function V(t,n){return function(){this.setAttribute(t,n)}}function X(t,n){return function(){this.setAttributeNS(t.space,t.local,n)}}function z(t,n){return function(){var e=n.apply(this,arguments);null==e?this.removeAttribute(t):this.setAttribute(t,e)}}function H(t,n){return function(){var e=n.apply(this,arguments);null==e?this.removeAttributeNS(t.space,t.local):this.setAttributeNS(t.space,t.local,e)}}function I(t,n){var e=D(t);if(arguments.length<2){var r=this.node();return e.local?r.getAttributeNS(e.space,e.local):r.getAttribute(e)}return this.each((null==n?e.local?R:O:"function"==typeof n?e.local?H:z:e.local?X:V)(e,n))}function U(t){return function(){this.style.removeProperty(t)}}function Y(t,n,e){return function(){this.style.setProperty(t,n,e)}}function $(t,n,e){return function(){var r=n.apply(this,arguments);null==r?this.style.removeProperty(t):this.style.setProperty(t,r,e)}}function j(t,n,e){var r;return arguments.length>1?this.each((null==n?U:"function"==typeof n?$:Y)(t,n,null==e?"":e)):l(r=this.node()).getComputedStyle(r,null).getPropertyValue(t)}function k(t){return function(){delete this[t]}}function G(t,n){return function(){this[t]=n}}function K(t,n){return function(){var e=n.apply(this,arguments);null==e?delete this[t]:this[t]=e}}function W(t,n){return arguments.length>1?this.each((null==n?k:"function"==typeof n?K:G)(t,n)):this.node()[t]}function F(t){return t.trim().split(/^|\s+/)}function J(t){return t.classList||new Q(t)}function Q(t){this._node=t,this._names=F(t.getAttribute("class")||"")}function Z(t,n){for(var e=J(t),r=-1,i=n.length;++r<i;)e.add(n[r])}function tt(t,n){for(var e=J(t),r=-1,i=n.length;++r<i;)e.remove(n[r])}function nt(t){return function(){Z(this,t)}}function et(t){return function(){tt(this,t)}}function rt(t,n){return function(){(n.apply(this,arguments)?Z:tt)(this,t)}}function it(t,n){var e=F(t+"");if(arguments.length<2){for(var r=J(this.node()),i=-1,o=e.length;++i<o;)if(!r.contains(e[i]))return!1;return!0}return this.each(("function"==typeof n?rt:n?nt:et)(e,n))}function ot(){this.textContent=""}function ut(t){return function(){this.textContent=t}}function st(t){return function(){var n=t.apply(this,arguments);this.textContent=null==n?"":n}}function at(t){return arguments.length?this.each(null==t?ot:("function"==typeof t?st:ut)(t)):this.node().textContent}function ct(){this.innerHTML=""}function lt(t){return function(){this.innerHTML=t}}function ht(t){return function(){var n=t.apply(this,arguments);this.innerHTML=null==n?"":n}}function ft(t){return arguments.length?this.each(null==t?ct:("function"==typeof t?ht:lt)(t)):this.node().innerHTML}function pt(){this.parentNode.appendChild(this)}function dt(){return this.each(pt)}function _t(){this.parentNode.insertBefore(this,this.parentNode.firstChild)}function mt(){return this.each(_t)}function vt(t){return function(){var n=this.ownerDocument,e=this.namespaceURI;return e&&e!==n.documentElement.namespaceURI?n.createElementNS(e,t):n.createElement(t)}}function gt(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function yt(t){var n=D(t);return(n.local?gt:vt)(n)}function wt(t){return function(){return this.appendChild(t.apply(this,arguments))}}function xt(t,n){return function(){return this.insertBefore(t.apply(this,arguments),n.apply(this,arguments)||null)}}function At(){return null}function St(t,n){var e="function"==typeof t?t:yt(t);return this.select(arguments.length<2?wt(e):xt(e,null==n?At:"function"==typeof n?n:h(n)))}function bt(){var t=this.parentNode;t&&t.removeChild(this)}function Et(){return this.each(bt)}function Ct(t){return arguments.length?this.property("__data__",t):this.node().__data__}function Nt(t,n,e){var r=l(t),i=r.CustomEvent;i?i=new i(n,e):(i=r.document.createEvent("Event"),e?(i.initEvent(n,e.bubbles,e.cancelable),i.detail=e.detail):i.initEvent(n,!1,!1)),t.dispatchEvent(i)}function Mt(t,n){return function(){return Nt(this,t,n)}}function Tt(t,n){return function(){return Nt(this,t,n.apply(this,arguments))}}function Lt(t,n){return this.each(("function"==typeof n?Tt:Mt)(t,n))}function Pt(t,n){this._nodes=t,this._parents=n}function qt(){return new Pt([[document.documentElement]],Kt)}function Bt(t){return"string"==typeof t?new Pt([[document.querySelector(t)]],[document.documentElement]):new Pt([[t]],Kt)}function Dt(t,n){var e=t.ownerSVGElement||t;if(e.createSVGPoint){var r=e.createSVGPoint();if(0>Wt){var i=l(t);if(i.scrollX||i.scrollY){e=Bt(i.document.body).append("svg").style({position:"absolute",top:0,left:0,margin:0,padding:0,border:"none"},"important");var o=e.node().getScreenCTM();Wt=!(o.f||o.e),e.remove()}}return Wt?(r.x=n.pageX,r.y=n.pageY):(r.x=n.clientX,r.y=n.clientY),r=r.matrixTransform(t.getScreenCTM().inverse()),[r.x,r.y]}var u=t.getBoundingClientRect();return[n.clientX-u.left-t.clientLeft,n.clientY-u.top-t.clientTop]}function Ot(t,n){return null==n&&(n=c()),n.changedTouches&&(n=n.changedTouches[0]),Dt(t,n)}function Rt(t){return"string"==typeof t?new Pt([document.querySelectorAll(t)],[document.documentElement]):new Pt([t],Kt)}function Vt(t,n,e){arguments.length<3&&(e=n,n=c().changedTouches);for(var r,i=0,o=n?n.length:0;o>i;++i)if((r=n[i]).identifier===e)return Dt(t,r);return null}function Xt(t,n){null==n&&(n=c().touches);for(var e=0,r=n?n.length:0,i=new Array(r);r>e;++e)i[e]=Dt(t,n[e]);return i}var zt=/[\\\^\$\*\+\?\|\[\]\(\)\.\{\}]/g,Ht={};if(t.event=null,"undefined"!=typeof document){var It=document.documentElement;"onmouseenter"in It||(Ht={mouseenter:"mouseover",mouseleave:"mouseout"})}var Ut=function(t){return function(){return this.matches(t)}};if("undefined"!=typeof document){var Yt=document.documentElement;if(!Yt.matches){var $t=Yt.webkitMatchesSelector||Yt.msMatchesSelector||Yt.mozMatchesSelector||Yt.oMatchesSelector;Ut=function(t){return function(){return $t.call(this,t)}}}}var jt=Ut,kt="$";x.prototype={appendChild:function(t){return this._parent.insertBefore(t,this._next)},insertBefore:function(t,n){return this._parent.insertBefore(t,n)},querySelector:function(t){return this._parent.querySelector(t)},querySelectorAll:function(t){return this._parent.querySelectorAll(t)}};var Gt={svg:"http://www.w3.org/2000/svg",xhtml:"http://www.w3.org/1999/xhtml",xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};Q.prototype={add:function(t){var n=this._names.indexOf(t);0>n&&(this._names.push(t),this._node.setAttribute("class",this._names.join(" ")))},remove:function(t){var n=this._names.indexOf(t);n>=0&&(this._names.splice(n,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}};var Kt=[null];Pt.prototype=qt.prototype={select:f,selectAll:d,filter:_,data:w,enter:S,exit:b,order:E,sort:C,call:M,nodes:T,node:L,size:P,empty:q,each:B,attr:I,style:j,property:W,classed:it,text:at,html:ft,raise:dt,lower:mt,append:St,remove:Et,datum:Ct,on:a,dispatch:Lt};var Wt="undefined"!=typeof navigator&&/WebKit/.test(navigator.userAgent)?-1:0,Ft="0.6.5";t.version=Ft,t.mouse=Ot,t.namespace=D,t.namespaces=Gt,t.select=Bt,t.selectAll=Rt,t.selection=qt,t.touch=Vt,t.touches=Xt}); |
{ | ||
"name": "d3-selection", | ||
"version": "0.6.3", | ||
"version": "0.6.5", | ||
"description": "Data-driven DOM manipulation: select elements and join them to data.", | ||
@@ -24,10 +24,11 @@ "keywords": [ | ||
"scripts": { | ||
"pretest": "mkdir -p build && node -e 'process.stdout.write(\"var version = \\\"\" + require(\"./package.json\").version + \"\\\"; export * from \\\"../index\\\"; export {version};\");' > build/bundle.js && rollup -f umd -u d3-selection -n d3_selection -o build/d3-selection.js -- build/bundle.js", | ||
"pretest": "mkdir -p build && node -e 'process.stdout.write(\"var version = \\\"\" + require(\"./package.json\").version + \"\\\"; export * from \\\"../index\\\"; export {version};\");' > build/bundle.js && rollup -f umd -n d3_selection -o build/d3-selection.js -- build/bundle.js", | ||
"test": "faucet `find test -name '*-test.js'` && eslint index.js src", | ||
"prepublish": "npm test && uglifyjs build/d3-selection.js -c -m -o build/d3-selection.min.js && rm -f build/d3-selection.zip && zip -j build/d3-selection.zip -- LICENSE README.md build/d3-selection.js build/d3-selection.min.js" | ||
"prepublish": "npm test && uglifyjs build/d3-selection.js -c -m -o build/d3-selection.min.js && rm -f build/d3-selection.zip && zip -j build/d3-selection.zip -- LICENSE README.md build/d3-selection.js build/d3-selection.min.js", | ||
"postpublish": "VERSION=`node -e 'console.log(require(\"./package.json\").version)'`; git push && git tag -am \"Release $VERSION.\" v${VERSION} && git push --tags && cp build/d3-selection.js ../d3.github.com/d3-selection.v0.6.js && cp build/d3-selection.min.js ../d3.github.com/d3-selection.v0.6.min.js && cd ../d3.github.com && git add d3-selection.v0.6.js d3-selection.v0.6.min.js && git commit -m \"d3-selection ${VERSION}\" && git push" | ||
}, | ||
"devDependencies": { | ||
"faucet": "0.0", | ||
"rollup": "0.20.5", | ||
"jsdom": "7", | ||
"rollup": "0.25", | ||
"jsdom": "8", | ||
"tape": "4", | ||
@@ -34,0 +35,0 @@ "uglify-js": "2" |
@@ -231,3 +231,3 @@ # d3-selection | ||
d3.selectAll("p").append(function() { | ||
return document.createElement("DIV"); | ||
return document.createElement("div"); | ||
}); | ||
@@ -234,0 +234,0 @@ ``` |
@@ -1,27 +0,4 @@ | ||
import namespace from "../namespace"; | ||
import creator from "../creator"; | ||
import selector from "../selector"; | ||
function creatorInherit(name) { | ||
return function() { | ||
var document = this.ownerDocument, | ||
uri = this.namespaceURI; | ||
return uri && uri !== document.documentElement.namespaceURI | ||
? document.createElementNS(uri, name) | ||
: document.createElement(name); | ||
}; | ||
} | ||
function creatorFixed(fullname) { | ||
return function() { | ||
return this.ownerDocument.createElementNS(fullname.space, fullname.local); | ||
}; | ||
} | ||
function creator(name) { | ||
var fullname = namespace(name); | ||
return (fullname.local | ||
? creatorFixed | ||
: creatorInherit)(fullname); | ||
} | ||
function append(create) { | ||
@@ -28,0 +5,0 @@ return function() { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
109645
56
1631