A small optimisation: only call insertBefore() if node.nextSibling isn't
already what we want, so that document nodes that are already in the
correct order can be skipped.
This commit is contained in:
Jason Davies 2011-12-31 09:28:42 +00:00
Родитель a92f8b3ed0
Коммит b9a03ad84a
3 изменённых файлов: 3 добавлений и 3 удалений

2
d3.js поставляемый
Просмотреть файл

@ -1777,7 +1777,7 @@ d3_selectionPrototype.order = function() {
for (var j = -1, m = this.length; ++j < m;) { for (var j = -1, m = this.length; ++j < m;) {
for (var group = this[j], i = group.length - 1, next = group[i], node; --i >= 0;) { for (var group = this[j], i = group.length - 1, next = group[i], node; --i >= 0;) {
if (node = group[i]) { if (node = group[i]) {
if (next) next.parentNode.insertBefore(node, next); if (next && next !== node.nextSibling) next.parentNode.insertBefore(node, next);
next = node; next = node;
} }
} }

2
d3.min.js поставляемый

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Просмотреть файл

@ -2,7 +2,7 @@ d3_selectionPrototype.order = function() {
for (var j = -1, m = this.length; ++j < m;) { for (var j = -1, m = this.length; ++j < m;) {
for (var group = this[j], i = group.length - 1, next = group[i], node; --i >= 0;) { for (var group = this[j], i = group.length - 1, next = group[i], node; --i >= 0;) {
if (node = group[i]) { if (node = group[i]) {
if (next) next.parentNode.insertBefore(node, next); if (next && next !== node.nextSibling) next.parentNode.insertBefore(node, next);
next = node; next = node;
} }
} }