d3-selection
Advanced tools
Comparing version 0.4.8 to 0.4.9
101
build/d3.js
@@ -1,20 +0,1 @@ | ||
if (typeof Map === "undefined") { | ||
Map = function() { this.clear(); }; | ||
Map.prototype = { | ||
set: function(k, v) { this._[k] = v; return this; }, | ||
get: function(k) { return this._[k]; }, | ||
has: function(k) { return k in this._; }, | ||
delete: function(k) { return k in this._ && delete this._[k]; }, | ||
clear: function() { this._ = Object.create(null); }, | ||
get size() { var n = 0; for (var k in this._) ++n; return n; }, | ||
forEach: function(c) { for (var k in this._) c(this._[k], k, this); } | ||
}; | ||
} else (function() { | ||
var m = new Map; | ||
if (m.set(0, 0) !== m) { | ||
m = m.set; | ||
Map.prototype.set = function() { m.apply(this, arguments); return this; }; | ||
} | ||
})(); | ||
(function (global, factory) { | ||
@@ -44,5 +25,3 @@ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : | ||
return this.each(typeof params === "function" ? dispatchFunction : dispatchConstant); | ||
} | ||
function dispatchEvent(node, type, params) { | ||
}function dispatchEvent(node, type, params) { | ||
var window = _defaultView(node), | ||
@@ -70,3 +49,3 @@ event = window.CustomEvent; | ||
var event = null; | ||
var _event = null; | ||
@@ -124,13 +103,11 @@ if (typeof document !== "undefined") { | ||
: (n ? remove : removeAll)); | ||
} | ||
function listenerOf(listener, ancestors, args) { | ||
}function listenerOf(listener, ancestors, args) { | ||
return function(event1) { | ||
var i = ancestors.length, event0 = event; // Events can be reentrant (e.g., focus). | ||
var i = ancestors.length, event0 = _event; // Events can be reentrant (e.g., focus). | ||
while (--i >= 0) args[i << 1] = ancestors[i].__data__; | ||
event = event1; | ||
_event = event1; | ||
try { | ||
listener.apply(ancestors[0], args); | ||
} finally { | ||
event = event0; | ||
_event = event0; | ||
} | ||
@@ -177,3 +154,3 @@ }; | ||
var i = name.indexOf(":"), prefix = name; | ||
if (i >= 0) prefix = name.slice(0, i), name = name.slice(i + 1); | ||
if (i >= 0 && (prefix = name.slice(0, i)) !== "xmlns") name = name.slice(i + 1); | ||
return namespaces.has(prefix) ? {space: namespaces.get(prefix), local: name} : name; | ||
@@ -196,5 +173,3 @@ } | ||
: (typeof selector !== "function" && (selector = selectorOf(selector)), insert)); | ||
} | ||
function creatorOf(name) { | ||
}function creatorOf(name) { | ||
name = namespace(name); | ||
@@ -279,5 +254,3 @@ | ||
return this.each(typeof value === "function" ? setFunction : setConstant); | ||
} | ||
function classerOf(name) { | ||
}function classerOf(name) { | ||
var re; | ||
@@ -440,5 +413,3 @@ return function(node, value) { | ||
return firstNode(this._root, this._depth); | ||
} | ||
function firstNode(nodes, depth) { | ||
}function firstNode(nodes, depth) { | ||
var i = -1, | ||
@@ -479,3 +450,2 @@ n = nodes.length, | ||
// The leaf groups of the selection hierarchy are initially NodeList, | ||
@@ -485,5 +455,3 @@ // and then lazily converted to arrays when mutation is required. | ||
return selection._root = arrayifyNode(selection._root, selection._depth); | ||
} | ||
function arrayifyNode(nodes, depth) { | ||
}function arrayifyNode(nodes, depth) { | ||
var i = -1, | ||
@@ -537,5 +505,3 @@ n = nodes.length, | ||
return this.order(); | ||
} | ||
function ascending(a, b) { | ||
}function ascending(a, b) { | ||
return a < b ? -1 : a > b ? 1 : a >= b ? 0 : NaN; | ||
@@ -547,5 +513,3 @@ } | ||
return this; | ||
} | ||
function orderNode(nodes, depth) { | ||
}function orderNode(nodes, depth) { | ||
var i = nodes.length, | ||
@@ -576,5 +540,3 @@ node, | ||
return new Selection(emptyNode(arrayify(selection), selection._depth), selection._depth); | ||
} | ||
function emptyNode(nodes, depth) { | ||
}function emptyNode(nodes, depth) { | ||
var i = -1, | ||
@@ -597,3 +559,2 @@ n = nodes.length, | ||
// Lazily constructs the exit selection for this (update) selection. | ||
@@ -605,3 +566,2 @@ // Until this selection is joined to data, the exit selection will be empty. | ||
// Lazily constructs the enter selection for this (update) selection. | ||
@@ -617,3 +577,2 @@ // Until this selection is joined to data, the enter selection will be empty. | ||
// The value may either be an array or a function that returns an array. | ||
@@ -781,5 +740,3 @@ // An optional key function may be specified to control how data is bound; | ||
return this; | ||
} | ||
function EnterNode(parent, datum) { | ||
}function EnterNode(parent, datum) { | ||
this.ownerDocument = parent.ownerDocument; | ||
@@ -803,3 +760,2 @@ this.namespaceURI = parent.namespaceURI; | ||
// The filter may either be a selector string (e.g., ".foo") | ||
@@ -850,5 +806,3 @@ // or a function that returns a boolean. | ||
return new Selection(visit(this._root, depth), depth); | ||
} | ||
var filterOf = function(selector) { | ||
}var filterOf = function(selector) { | ||
return function() { | ||
@@ -867,3 +821,2 @@ return this.matches(selector); | ||
// The selector may either be a selector string (e.g., ".foo") | ||
@@ -913,5 +866,3 @@ // or a function that optionally returns an array of nodes to select. | ||
return new Selection(visit(this._root, depth), depth + 1); | ||
} | ||
function selectorAllOf(selector) { | ||
}function selectorAllOf(selector) { | ||
return function() { | ||
@@ -922,3 +873,2 @@ return this.querySelectorAll(selector); | ||
// The selector may either be a selector string (e.g., ".foo") | ||
@@ -974,3 +924,2 @@ // or a function that optionally returns the node to select. | ||
// When depth = 1, root = [Node, …]. | ||
@@ -984,9 +933,7 @@ // When depth = 2, root = [[Node, …], …]. | ||
this._enter = this._update = this._exit = null; | ||
} | ||
function selection() { | ||
}function _selection() { | ||
return new Selection([document.documentElement], 1); | ||
} | ||
Selection.prototype = selection.prototype = { | ||
Selection.prototype = _selection.prototype = { | ||
select: selection_select, | ||
@@ -1051,3 +998,3 @@ selectAll: selection_selectAll, | ||
function sourceEvent() { | ||
var current = event, source; | ||
var current = _event, source; | ||
while (source = current.sourceEvent) current = source; | ||
@@ -1057,3 +1004,3 @@ return current; | ||
function touches(node, touches) { | ||
function _touches(node, touches) { | ||
if (arguments.length < 2) touches = sourceEvent().touches; | ||
@@ -1087,3 +1034,3 @@ for (var i = 0, n = touches ? touches.length : 0, points = new Array(n); i < n; ++i) { | ||
var d3 = { | ||
get event() { return event; }, | ||
get event() { return _event; }, | ||
mouse: mouse, | ||
@@ -1095,5 +1042,5 @@ namespace: namespace, | ||
selectAll: selectAll, | ||
selection: selection, | ||
selection: _selection, | ||
touch: touch, | ||
touches: touches | ||
touches: _touches | ||
}; | ||
@@ -1100,0 +1047,0 @@ |
{ | ||
"name": "d3-selection", | ||
"version": "0.4.8", | ||
"version": "0.4.9", | ||
"description": "Data-driven DOM manipulation: select elements and join them to data.", | ||
@@ -17,3 +17,3 @@ "keywords": [ | ||
}, | ||
"main": "build/d3", | ||
"main": "build/selection", | ||
"jsnext:main": "index", | ||
@@ -25,8 +25,8 @@ "repository": { | ||
"scripts": { | ||
"pretest": "mkdir -p build && d3-bundler --polyfill-map --format=umd --name=d3 -- d3.js > build/d3.js", | ||
"pretest": "mkdir -p build && d3-bundler --format=umd --name=selection -- index.js > build/selection.js", | ||
"test": "faucet `find test -name '*-test.js'`", | ||
"prepublish": "npm run test && uglifyjs build/d3.js -c -m -o build/d3.min.js && rm -f build/d3.zip && zip -j build/d3.zip -- LICENSE README.md build/d3.js build/d3.min.js" | ||
"prepublish": "npm run test && uglifyjs build/selection.js -c -m -o build/selection.min.js && rm -f build/selection.zip && zip -j build/selection.zip -- LICENSE README.md build/selection.js build/selection.min.js" | ||
}, | ||
"devDependencies": { | ||
"d3-bundler": "~0.2.5", | ||
"d3-bundler": "~0.3.0", | ||
"faucet": "0.0", | ||
@@ -33,0 +33,0 @@ "jsdom": "3", |
@@ -25,3 +25,3 @@ # d3-selection | ||
* The d3.ns.prefix namespace map has been renamed to d3.namespaces and is now a Map rather than an object. | ||
* The d3.ns.prefix namespace map has been renamed to d3.namespaces. | ||
@@ -28,0 +28,0 @@ * The d3.ns.qualify method has been renamed to d3.namespace. |
@@ -5,4 +5,4 @@ import namespaces from "./namespaces"; | ||
var i = name.indexOf(":"), prefix = name; | ||
if (i >= 0) prefix = name.slice(0, i), name = name.slice(i + 1); | ||
return namespaces.has(prefix) ? {space: namespaces.get(prefix), local: name} : name; | ||
if (i >= 0 && (prefix = name.slice(0, i)) !== "xmlns") name = name.slice(i + 1); | ||
return namespaces.hasOwnProperty(prefix) ? {space: namespaces[prefix], local: name} : name; | ||
}; |
@@ -1,6 +0,7 @@ | ||
export default (new Map) | ||
.set("svg", "http://www.w3.org/2000/svg") | ||
.set("xhtml", "http://www.w3.org/1999/xhtml") | ||
.set("xlink", "http://www.w3.org/1999/xlink") | ||
.set("xml", "http://www.w3.org/XML/1998/namespace") | ||
.set("xmlns", "http://www.w3.org/2000/xmlns/"); | ||
export default { | ||
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/" | ||
}; |
@@ -0,1 +1,3 @@ | ||
var keyPrefix = "$"; | ||
// The value may either be an array or a function that returns an array. | ||
@@ -99,3 +101,3 @@ // An optional key function may be specified to control how data is bound; | ||
nodeLength = update.length, | ||
nodeByKeyValue = new Map, | ||
nodeByKeyValue = {}, | ||
keyStack = new Array(2).concat(stack), | ||
@@ -113,7 +115,7 @@ keyValues = new Array(nodeLength), | ||
keyStack[0] = node.__data__, keyStack[1] = i; | ||
keyValues[i] = keyValue = key.apply(node, keyStack); | ||
keyValues[i] = keyValue = keyPrefix + key.apply(node, keyStack); | ||
// Is this a duplicate of a key we’ve previously seen? | ||
// If so, this node is moved to the exit selection. | ||
if (nodeByKeyValue.has(keyValue)) { | ||
if (nodeByKeyValue[keyValue]) { | ||
exit[i] = node; | ||
@@ -124,3 +126,3 @@ } | ||
else { | ||
nodeByKeyValue.set(keyValue, node); | ||
nodeByKeyValue[keyValue] = node; | ||
} | ||
@@ -136,7 +138,7 @@ } | ||
keyStack[0] = data[i], keyStack[1] = i; | ||
keyValue = key.apply(update._parent, keyStack); | ||
keyValue = keyPrefix + key.apply(update._parent, keyStack); | ||
// Is there a node associated with this key? | ||
// If not, this datum is added to the enter selection. | ||
if (!(node = nodeByKeyValue.get(keyValue))) { | ||
if (!(node = nodeByKeyValue[keyValue])) { | ||
enter[i] = new EnterNode(update._parent, data[i]); | ||
@@ -154,3 +156,3 @@ } | ||
// Record that we consumed this key, either to enter or update. | ||
nodeByKeyValue.set(keyValue, true); | ||
nodeByKeyValue[keyValue] = true; | ||
} | ||
@@ -161,3 +163,3 @@ | ||
for (i = 0; i < nodeLength; ++i) { | ||
if ((node = nodeByKeyValue.get(keyValues[i])) !== true) { | ||
if ((node = nodeByKeyValue[keyValues[i]]) !== true) { | ||
exit[i] = node; | ||
@@ -164,0 +166,0 @@ } |
import requote from "./requote"; | ||
var filterEvents = new Map; | ||
var filterEvents = {}; | ||
@@ -10,3 +10,3 @@ export var event = null; | ||
if (!("onmouseenter" in element)) { | ||
filterEvents.set("mouseenter", "mouseover").set("mouseleave", "mouseout"); | ||
filterEvents = {mouseenter: "mouseover", mouseleave: "mouseout"}; | ||
} | ||
@@ -25,3 +25,3 @@ } | ||
if ((n = type.indexOf(".")) > 0) type = type.slice(0, n); | ||
if (filter = filterEvents.has(type)) type = filterEvents.get(type); | ||
if (filter = filterEvents.hasOwnProperty(type)) type = filterEvents[type]; | ||
@@ -28,0 +28,0 @@ function add() { |
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
121217
49
2638