Fixes#2061. A line segment with a single point is now rendered as "M2,3Z"
rather than "M2,3", such that if there is an associated stroke-linecap, it is
displayed correctly.
When a scheduled transition is pre-empted by a newer transition starting, we now
cancel the old transition’s timers immediately, rather than waiting for the old
transition to start.
Fixes#2377. Related #2189.
Also add tests for d3_documentElement and d3_window so that they work for the
three cases we care about: a node, a document and a window. For anything else
they return undefined.
d3.select(window) calls d3_documentElement(window), which fails since
window objects don’t have an ownerDocument property. This fix falls
back to using node.document if node.ownerDocument doesn’t exist.
Code that previously assumed a global document or window now uses the related
node’s ownerDocument or ownerDocument.defaultView as appropriate.
If no related node is available, the corresponding code will crash; however, the
rest of D3 will work just fine. For example, you can’t use d3.select(string)
unless a global document is available; it just doesn’t make sense. Use
d3.select(node) instead, followed by selection.select(string).
Code that previously checked for a global on the window (e.g., XDomainRequest)
now uses the global context (`this`) rather than the window.
Even if no further transitions are scheduled on the element, we must still
advance the active counter to interrupt the active transition. Fixes#2165. Also
added better tests that verify interruption.
Normally selection.append is only called on normal elements that have a defined
namespaceURI. However, if createElement is called on a shadow root, then
namespaceURI is null. Now we correctly fallback to createElement instead of
createElementNS in this case. Fixes#2161.
When a transition is interrupted, the interrupt event is dispatched immediately
(such as within a call to selection.interrupt). This is easier to understand and
guarantees that the interrupt event on an interrupted transition is dispatched
prior to the start event on an interrupting transition, fixing #2140.
Calling selection.interrupt repeatedly no longer cancels any scheduled (but
inactive) transitions, fixing #2141. Calling selection.interrupt when there is
no active transition now has no effect.
An interrupt event is only dispatched if the active transition is interrupted,
and not if a scheduled transition was cancelled, as when a delayed transition is
superceded by an earlier transition on the same element. These transitions are
cancelled silently, fixing #2144.
Lastly, transition event listeners now see the latest bound data, rather than
using the data that was captured shortly after the transition was scheduled.
Fixes#2142.