Skip to content

Commit e15ac86

Browse files
committed
Merge branch '3.1.10'
2 parents eb38418 + fcbf4f2 commit e15ac86

19 files changed

Lines changed: 202 additions & 161 deletions

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ d3.js: $(shell node_modules/.bin/smash --list src/d3.js) package.json
3131

3232
d3.min.js: d3.js
3333
@rm -f $@
34-
node_modules/.bin/uglifyjs $< -c -m -o $@
34+
bin/uglify $< > $@
3535

3636
component.json: bin/component d3.js package.json
3737
@rm -f $@

bin/uglify

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/usr/bin/env node
2+
3+
var fs = require("fs"),
4+
uglify = require("uglify-js");
5+
6+
var filename = process.argv[2],
7+
toplevel = uglify.parse(fs.readFileSync(filename, "utf8"), {filename: filename}),
8+
output = uglify.OutputStream(),
9+
compressor = uglify.Compressor(true),
10+
warn = uglify.AST_Node.warn;
11+
12+
uglify.AST_Node.warn = function(s, o) {
13+
if (o.msg === "Accidental global?" && o.name === "d3" && o.line === 1 && !o.col) return;
14+
warn.apply(this, arguments);
15+
};
16+
17+
toplevel.figure_out_scope();
18+
toplevel.scope_warnings({
19+
undeclared: false,
20+
unreferenced: false,
21+
assign_to_global: true,
22+
func_arguments: false,
23+
nested_defuns: false,
24+
eval: false
25+
});
26+
27+
toplevel = toplevel.transform(compressor);
28+
29+
toplevel.figure_out_scope();
30+
toplevel.compute_char_frequency(true);
31+
toplevel.mangle_names(true);
32+
toplevel.print(output);
33+
34+
require("util").print(output.get());

component.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "d3",
3-
"version": "3.1.9",
3+
"version": "3.1.10",
44
"main": "index-browserify.js",
55
"scripts": [
66
"index-browserify.js",

d3.js

Lines changed: 55 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
d3 = function() {
22
var d3 = {
3-
version: "3.1.9"
3+
version: "3.1.10"
44
};
55
if (!Date.now) Date.now = function() {
66
return +new Date();
@@ -1628,14 +1628,32 @@ d3 = function() {
16281628
function d3_identity(d) {
16291629
return d;
16301630
}
1631-
d3.xhr = function(url, mimeType, callback) {
1632-
var xhr = {}, dispatch = d3.dispatch("progress", "load", "error"), headers = {}, response = d3_identity, request = new (d3_window.XDomainRequest && /^(http(s)?:)?\/\//.test(url) ? XDomainRequest : XMLHttpRequest)();
1631+
d3.xhr = d3_xhrType(d3_identity);
1632+
function d3_xhrType(response) {
1633+
return function(url, mimeType, callback) {
1634+
if (arguments.length === 2 && typeof mimeType === "function") callback = mimeType,
1635+
mimeType = null;
1636+
return d3_xhr(url, mimeType, response, callback);
1637+
};
1638+
}
1639+
function d3_xhr(url, mimeType, response, callback) {
1640+
var xhr = {}, dispatch = d3.dispatch("progress", "load", "error"), headers = {}, request = new (d3_window.XDomainRequest && /^(http(s)?:)?\/\//.test(url) ? XDomainRequest : XMLHttpRequest)();
16331641
"onload" in request ? request.onload = request.onerror = respond : request.onreadystatechange = function() {
16341642
request.readyState > 3 && respond();
16351643
};
16361644
function respond() {
1637-
var s = request.status;
1638-
!s && request.responseText || s >= 200 && s < 300 || s === 304 ? dispatch.load.call(xhr, response.call(xhr, request)) : dispatch.error.call(xhr, request);
1645+
var status = request.status, result;
1646+
if (!status && request.responseText || status >= 200 && status < 300 || status === 304) {
1647+
try {
1648+
result = response.call(xhr, request);
1649+
} catch (e) {
1650+
dispatch.error.call(xhr, e);
1651+
return;
1652+
}
1653+
dispatch.load.call(xhr, result);
1654+
} else {
1655+
dispatch.error.call(xhr, request);
1656+
}
16391657
}
16401658
request.onprogress = function(event) {
16411659
var o = d3.event;
@@ -1683,10 +1701,8 @@ d3 = function() {
16831701
return xhr;
16841702
};
16851703
d3.rebind(xhr, dispatch, "on");
1686-
if (arguments.length === 2 && typeof mimeType === "function") callback = mimeType,
1687-
mimeType = null;
16881704
return callback == null ? xhr : xhr.get(d3_xhr_fixCallback(callback));
1689-
};
1705+
}
16901706
function d3_xhr_fixCallback(callback) {
16911707
return callback.length === 1 ? function(error, request) {
16921708
callback(error == null ? request : null);
@@ -1796,36 +1812,28 @@ d3 = function() {
17961812
}
17971813
d3.csv = d3_dsv(",", "text/csv");
17981814
d3.tsv = d3_dsv(" ", "text/tab-separated-values");
1799-
var d3_timer_id = 0, d3_timer_byId = {}, d3_timer_queue = null, d3_timer_interval, d3_timer_timeout;
1815+
var d3_timer_queueHead, d3_timer_queueTail, d3_timer_interval, d3_timer_timeout;
18001816
d3.timer = function(callback, delay, then) {
18011817
if (arguments.length < 3) {
18021818
if (arguments.length < 2) delay = 0; else if (!isFinite(delay)) return;
18031819
then = Date.now();
18041820
}
1805-
var timer = d3_timer_byId[callback.id];
1806-
if (timer && timer.callback === callback) {
1807-
timer.then = then;
1808-
timer.delay = delay;
1809-
} else d3_timer_byId[callback.id = ++d3_timer_id] = d3_timer_queue = {
1821+
var time = then + delay;
1822+
var timer = {
18101823
callback: callback,
1811-
then: then,
1812-
delay: delay,
1813-
next: d3_timer_queue
1824+
time: time,
1825+
next: null
18141826
};
1827+
if (d3_timer_queueTail) d3_timer_queueTail.next = timer; else d3_timer_queueHead = timer;
1828+
d3_timer_queueTail = timer;
18151829
if (!d3_timer_interval) {
18161830
d3_timer_timeout = clearTimeout(d3_timer_timeout);
18171831
d3_timer_interval = 1;
18181832
d3_timer_frame(d3_timer_step);
18191833
}
18201834
};
18211835
function d3_timer_step() {
1822-
var elapsed, now = Date.now(), t1 = d3_timer_queue;
1823-
while (t1) {
1824-
elapsed = now - t1.then;
1825-
if (elapsed >= t1.delay) t1.flush = t1.callback(elapsed);
1826-
t1 = t1.next;
1827-
}
1828-
var delay = d3_timer_flush() - now;
1836+
var now = d3_timer_mark(), delay = d3_timer_sweep() - now;
18291837
if (delay > 24) {
18301838
if (isFinite(delay)) {
18311839
clearTimeout(d3_timer_timeout);
@@ -1838,26 +1846,29 @@ d3 = function() {
18381846
}
18391847
}
18401848
d3.timer.flush = function() {
1841-
var elapsed, now = Date.now(), t1 = d3_timer_queue;
1842-
while (t1) {
1843-
elapsed = now - t1.then;
1844-
if (!t1.delay) t1.flush = t1.callback(elapsed);
1845-
t1 = t1.next;
1846-
}
1847-
d3_timer_flush();
1849+
d3_timer_mark();
1850+
d3_timer_sweep();
18481851
};
1849-
function d3_timer_flush() {
1850-
var t0 = null, t1 = d3_timer_queue, then = Infinity;
1852+
function d3_timer_mark() {
1853+
var now = Date.now(), timer = d3_timer_queueHead;
1854+
while (timer) {
1855+
if (now >= timer.time) timer.flush = timer.callback(now - timer.time);
1856+
timer = timer.next;
1857+
}
1858+
return now;
1859+
}
1860+
function d3_timer_sweep() {
1861+
var t0, t1 = d3_timer_queueHead, time = Infinity;
18511862
while (t1) {
18521863
if (t1.flush) {
1853-
delete d3_timer_byId[t1.callback.id];
1854-
t1 = t0 ? t0.next = t1.next : d3_timer_queue = t1.next;
1864+
t1 = t0 ? t0.next = t1.next : d3_timer_queueHead = t1.next;
18551865
} else {
1856-
then = Math.min(then, t1.then + t1.delay);
1866+
if (t1.time < time) time = t1.time;
18571867
t1 = (t0 = t1).next;
18581868
}
18591869
}
1860-
return then;
1870+
d3_timer_queueTail = t0;
1871+
return time;
18611872
}
18621873
var d3_timer_frame = d3_window.requestAnimationFrame || d3_window.webkitRequestAnimationFrame || d3_window.mozRequestAnimationFrame || d3_window.oRequestAnimationFrame || d3_window.msRequestAnimationFrame || function(callback) {
18631874
setTimeout(callback, 17);
@@ -2777,7 +2788,7 @@ d3 = function() {
27772788
function insidePolygon(p) {
27782789
var wn = 0, n = polygon.length, y = p[1];
27792790
for (var i = 0; i < n; ++i) {
2780-
for (var j = 1, v = polygon[i], m = v.length, a = v[0]; j < m; ++j) {
2791+
for (var j = 1, v = polygon[i], m = v.length, a = v[0], b; j < m; ++j) {
27812792
b = v[j];
27822793
if (a[1] <= y) {
27832794
if (b[1] > y && isLeft(a, b, p) > 0) ++wn;
@@ -8550,31 +8561,25 @@ d3 = function() {
85508561
d3.time.scale.utc = function() {
85518562
return d3_time_scale(d3.scale.linear(), d3_time_scaleUTCMethods, d3_time_scaleUTCFormat);
85528563
};
8553-
d3.text = function() {
8554-
return d3.xhr.apply(d3, arguments).response(d3_text);
8555-
};
8556-
function d3_text(request) {
8564+
d3.text = d3_xhrType(function(request) {
85578565
return request.responseText;
8558-
}
8566+
});
85598567
d3.json = function(url, callback) {
8560-
return d3.xhr(url, "application/json", callback).response(d3_json);
8568+
return d3_xhr(url, "application/json", d3_json, callback);
85618569
};
85628570
function d3_json(request) {
85638571
return JSON.parse(request.responseText);
85648572
}
85658573
d3.html = function(url, callback) {
8566-
return d3.xhr(url, "text/html", callback).response(d3_html);
8574+
return d3_xhr(url, "text/html", d3_html, callback);
85678575
};
85688576
function d3_html(request) {
85698577
var range = d3_document.createRange();
85708578
range.selectNode(d3_document.body);
85718579
return range.createContextualFragment(request.responseText);
85728580
}
8573-
d3.xml = function() {
8574-
return d3.xhr.apply(d3, arguments).response(d3_xml);
8575-
};
8576-
function d3_xml(request) {
8581+
d3.xml = d3_xhrType(function(request) {
85778582
return request.responseXML;
8578-
}
8583+
});
85798584
return d3;
85808585
}();

d3.min.js

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "d3",
3-
"version": "3.1.9",
3+
"version": "3.1.10",
44
"description": "A small, free JavaScript library for manipulating documents based on data.",
55
"keywords": [
66
"dom",

src/event/timer.js

Lines changed: 30 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import "../core/document";
22

3-
var d3_timer_id = 0,
4-
d3_timer_byId = {},
5-
d3_timer_queue = null,
3+
var d3_timer_queueHead,
4+
d3_timer_queueTail,
65
d3_timer_interval, // is an interval (or frame) active?
76
d3_timer_timeout; // is a timeout active?
87

@@ -14,20 +13,13 @@ d3.timer = function(callback, delay, then) {
1413
then = Date.now();
1514
}
1615

17-
// If the callback's already in the queue, update it.
18-
var timer = d3_timer_byId[callback.id];
19-
if (timer && timer.callback === callback) {
20-
timer.then = then;
21-
timer.delay = delay;
22-
}
16+
var time = then + delay;
2317

24-
// Otherwise, add the callback to the queue.
25-
else d3_timer_byId[callback.id = ++d3_timer_id] = d3_timer_queue = {
26-
callback: callback,
27-
then: then,
28-
delay: delay,
29-
next: d3_timer_queue
30-
};
18+
// Add the callback to the tail of the queue.
19+
var timer = {callback: callback, time: time, next: null};
20+
if (d3_timer_queueTail) d3_timer_queueTail.next = timer;
21+
else d3_timer_queueHead = timer;
22+
d3_timer_queueTail = timer;
3123

3224
// Start animatin'!
3325
if (!d3_timer_interval) {
@@ -38,17 +30,8 @@ d3.timer = function(callback, delay, then) {
3830
};
3931

4032
function d3_timer_step() {
41-
var elapsed,
42-
now = Date.now(),
43-
t1 = d3_timer_queue;
44-
45-
while (t1) {
46-
elapsed = now - t1.then;
47-
if (elapsed >= t1.delay) t1.flush = t1.callback(elapsed);
48-
t1 = t1.next;
49-
}
50-
51-
var delay = d3_timer_flush() - now;
33+
var now = d3_timer_mark(),
34+
delay = d3_timer_sweep() - now;
5235
if (delay > 24) {
5336
if (isFinite(delay)) {
5437
clearTimeout(d3_timer_timeout);
@@ -62,34 +45,36 @@ function d3_timer_step() {
6245
}
6346

6447
d3.timer.flush = function() {
65-
var elapsed,
66-
now = Date.now(),
67-
t1 = d3_timer_queue;
48+
d3_timer_mark();
49+
d3_timer_sweep();
50+
};
6851

69-
while (t1) {
70-
elapsed = now - t1.then;
71-
if (!t1.delay) t1.flush = t1.callback(elapsed);
72-
t1 = t1.next;
52+
function d3_timer_mark() {
53+
var now = Date.now(),
54+
timer = d3_timer_queueHead;
55+
while (timer) {
56+
if (now >= timer.time) timer.flush = timer.callback(now - timer.time);
57+
timer = timer.next;
7358
}
74-
75-
d3_timer_flush();
76-
};
59+
return now;
60+
}
7761

7862
// Flush after callbacks to avoid concurrent queue modification.
79-
function d3_timer_flush() {
80-
var t0 = null,
81-
t1 = d3_timer_queue,
82-
then = Infinity;
63+
// Returns the time of the earliest active timer, post-sweep.
64+
function d3_timer_sweep() {
65+
var t0,
66+
t1 = d3_timer_queueHead,
67+
time = Infinity;
8368
while (t1) {
8469
if (t1.flush) {
85-
delete d3_timer_byId[t1.callback.id];
86-
t1 = t0 ? t0.next = t1.next : d3_timer_queue = t1.next;
70+
t1 = t0 ? t0.next = t1.next : d3_timer_queueHead = t1.next;
8771
} else {
88-
then = Math.min(then, t1.then + t1.delay);
72+
if (t1.time < time) time = t1.time;
8973
t1 = (t0 = t1).next;
9074
}
9175
}
92-
return then;
76+
d3_timer_queueTail = t0;
77+
return time;
9378
}
9479

9580
var d3_timer_frame = d3_window.requestAnimationFrame

src/geo/clip-view.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ function d3_geo_clipView(x0, y0, x1, y1) {
4949
y = p[1];
5050

5151
for (var i = 0; i < n; ++i) {
52-
for (var j = 1, v = polygon[i], m = v.length, a = v[0]; j < m; ++j) {
52+
for (var j = 1, v = polygon[i], m = v.length, a = v[0], b; j < m; ++j) {
5353
b = v[j];
5454
if (a[1] <= y) {
5555
if (b[1] > y && isLeft(a, b, p) > 0) ++wn;

src/start.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
d3 = (function(){
2-
var d3 = {version: "3.1.9"}; // semver
2+
var d3 = {version: "3.1.10"}; // semver

src/xhr/html.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import "../core/document";
22
import "xhr";
33

44
d3.html = function(url, callback) {
5-
return d3.xhr(url, "text/html", callback).response(d3_html);
5+
return d3_xhr(url, "text/html", d3_html, callback);
66
};
77

88
function d3_html(request) {

0 commit comments

Comments
 (0)