Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
MUR Drupal
d3-library
Commits
6fa6e04a
Commit
6fa6e04a
authored
Jul 02, 2013
by
Mike Bostock
Browse files
Remember last non-null following sibling.
This way, we don’t rescan the same null elements.
parent
99f6e657
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
d3.js
View file @
6fa6e04a
...
...
@@ -924,9 +924,12 @@ d3 = function() {
return
d3_selectionPrototype
.
insert
.
call
(
this
,
name
,
before
);
};
function
d3_selection_enterInsertBefore
(
enter
)
{
var
i0
,
j0
;
return
function
(
d
,
i
,
j
)
{
var
group
=
enter
[
j
].
update
,
n
=
group
.
length
,
node
;
while
(
++
i
<
n
&&
!
(
node
=
group
[
i
]))
;
if
(
j
!=
j0
)
j0
=
j
,
i0
=
0
;
if
(
i
>=
i0
)
i0
=
i
+
1
;
while
(
!
(
node
=
group
[
i0
])
&&
++
i0
<
n
)
;
return
node
;
};
}
...
...
d3.min.js
View file @
6fa6e04a
This diff is collapsed.
Click to expand it.
src/selection/enter-insert.js
View file @
6fa6e04a
...
...
@@ -7,11 +7,14 @@ d3_selection_enterPrototype.insert = function(name, before) {
};
function
d3_selection_enterInsertBefore
(
enter
)
{
var
i0
,
j0
;
return
function
(
d
,
i
,
j
)
{
var
group
=
enter
[
j
].
update
,
n
=
group
.
length
,
node
;
while
(
++
i
<
n
&&
!
(
node
=
group
[
i
]));
if
(
j
!=
j0
)
j0
=
j
,
i0
=
0
;
if
(
i
>=
i0
)
i0
=
i
+
1
;
while
(
!
(
node
=
group
[
i0
])
&&
++
i0
<
n
);
return
node
;
};
}
test/selection/insert-test.js
View file @
6fa6e04a
...
...
@@ -120,7 +120,7 @@ suite.addBatch({
return
body
;
},
"
inserts before the following updating sibling
"
:
function
(
body
)
{
var
data
=
[
"
peach
"
,
"
apple
"
,
"
banana
"
,
"
orange
"
,
"
apricot
"
];
var
data
=
[
"
peach
"
,
"
apple
"
,
"
apple2
"
,
"
apple3
"
,
"
banana
"
,
"
orange
"
,
"
apricot
"
];
body
.
selectAll
(
"
div
"
).
data
(
data
,
String
).
enter
().
insert
(
"
div
"
);
assert
.
deepEqual
(
body
.
selectAll
(
"
div
"
).
data
(),
data
);
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment