Socket
Socket
Sign inDemoInstall

d3-selection

Package Overview
Dependencies
Maintainers
1
Versions
58
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

d3-selection - npm Package Compare versions

Comparing version 0.5.0 to 0.5.1

2

build/bundle.js

@@ -1,1 +0,1 @@

var version = "0.5.0"; export * from "../index"; export {version};
var version = "0.5.1"; export * from "../index"; export {version};

@@ -773,3 +773,4 @@ (function (global, factory) {

appendChild: function(child) { return this._parent.insertBefore(child, this._next); },
insertBefore: function(child, next) { return this._parent.insertBefore(child, next || this._next); }
insertBefore: function(child, next) { return this._parent.insertBefore(child, next || this._next); },
querySelector: function(selector) { return this._parent.querySelector(selector); }
};

@@ -1038,3 +1039,3 @@

var version = "0.5.0";
var version = "0.5.1";

@@ -1041,0 +1042,0 @@ exports.version = version;

@@ -1,1 +0,1 @@

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define("d3-selection",["exports"],e):e(t.d3_selection={})}(this,function(t){"use strict";function e(t){return t.replace(rt,"\\$&")}function n(t,n,a){function u(){for(var e=p,o=arguments.length>>1,u=new Array(o);--o>=0;)e=e[arguments[(o<<1)+1]],u[o]=o?e._parent:e;var c=r(n,u,arguments);l&&(c=i(c)),s.call(this),this.addEventListener(t,this[f]=c,c._capture=a),c._listener=n}function s(){var e=this[f];e&&(this.removeEventListener(t,e,e._capture),delete this[f])}function c(){var n,r=new RegExp("^__on([^.]+)"+e(t)+"$");for(var i in this)if(n=i.match(r)){var o=this[i];this.removeEventListener(n[1],o,o._capture),delete this[i]}}var l,h=arguments.length,f="__on"+t,p=this._root;return 2>h?(h=this.node()[f])&&h._listener:(3>h&&(a=!1),(h=t.indexOf("."))>0&&(t=t.slice(0,h)),(l=it.hasOwnProperty(t))&&(t=it[t]),this.each(n?h?u:o:h?s:c))}function r(e,n,r){return function(i){for(var o=n.length,a=t.event;--o>=0;)r[o<<1]=n[o].__data__;t.event=i;try{e.apply(n[0],r)}finally{t.event=a}}}function i(t){return function(e){var n=e.relatedTarget;n&&(n===this||8&n.compareDocumentPosition(this))||t(e)}}function o(){}function a(){for(var e,n=t.event;e=n.sourceEvent;)n=e;return n}function u(t){return t&&(t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView)}function s(t,e){function n(){return c(this,t,e)}function r(){return c(this,t,e.apply(this,arguments))}return this.each("function"==typeof e?r:n)}function c(t,e,n){var r=u(t),i=r.CustomEvent;i?i=new i(e,n):(i=r.document.createEvent("Event"),n?(i.initEvent(e,n.bubbles,n.cancelable),i.detail=n.detail):i.initEvent(e,!1,!1)),t.dispatchEvent(i)}function l(t){return arguments.length?this.property("__data__",t):this.node().__data__}function h(){return this.each(function(){var t=this.parentNode;t&&t.removeChild(this)})}function f(t){var e=t.indexOf(":"),n=t;return e>=0&&"xmlns"!==(n=t.slice(0,e))&&(t=t.slice(e+1)),at.hasOwnProperty(n)?{space:at[n],local:t}:t}function p(t){return function(){return this.querySelector(t)}}function _(t,e){function n(){return this.appendChild(t.apply(this,arguments))}function r(){return this.insertBefore(t.apply(this,arguments),e.apply(this,arguments)||null)}return"function"!=typeof t&&(t=d(t)),this.select(arguments.length<2?n:("function"!=typeof e&&(e=p(e)),r))}function d(t){function e(){var e=this.ownerDocument,n=this.namespaceURI;return n?e.createElementNS(n,t):e.createElement(t)}function n(){return this.ownerDocument.createElementNS(t.space,t.local)}return t=f(t),t.local?n:e}function g(t){function e(){this.innerHTML=t}function n(){var e=t.apply(this,arguments);this.innerHTML=null==e?"":e}return arguments.length?(null==t&&(t=""),this.each("function"==typeof t?n:e)):this.node().innerHTML}function m(t){function e(){this.textContent=t}function n(){var e=t.apply(this,arguments);this.textContent=null==e?"":e}return arguments.length?(null==t&&(t=""),this.each("function"==typeof t?n:e)):this.node().textContent}function v(t,e){function n(){for(var n=-1;++n<i;)t[n](this,e)}function r(){for(var n=-1,r=e.apply(this,arguments);++n<i;)t[n](this,r)}t=(t+"").trim().split(/^|\s+/);var i=t.length;if(arguments.length<2){var o=this.node(),a=-1;if(e=o.classList){for(;++a<i;)if(!e.contains(t[a]))return!1}else for(e=o.getAttribute("class");++a<i;)if(!A(t[a]).test(e))return!1;return!0}return t=t.map(y),this.each("function"==typeof e?r:n)}function y(t){var e;return function(n,r){if(i=n.classList)return r?i.add(t):i.remove(t);e||(e=A(t));var i=n.getAttribute("class")||"";r?(e.lastIndex=0,e.test(i)||n.setAttribute("class",w(i+" "+t))):n.setAttribute("class",w(i.replace(e," ")))}}function w(t){return t.trim().replace(/\s+/g," ")}function A(t){return new RegExp("(?:^|\\s+)"+e(t)+"(?:\\s+|$)","g")}function x(t,e){function n(){delete this[t]}function r(){this[t]=e}function i(){var n=e.apply(this,arguments);null==n?delete this[t]:this[t]=n}return arguments.length<2?this.node()[t]:this.each(null==e?n:"function"==typeof e?i:r)}function b(t,e,n){function r(){this.style.removeProperty(t)}function i(){this.style.setProperty(t,e,n)}function o(){var r=e.apply(this,arguments);null==r?this.style.removeProperty(t):this.style.setProperty(t,r,n)}var a=arguments.length;return 2>a?u(a=this.node()).getComputedStyle(a,null).getPropertyValue(t):(3>a&&(n=""),this.each(null==e?r:"function"==typeof e?o:i))}function S(t,e){function n(){this.removeAttribute(t)}function r(){this.removeAttributeNS(t.space,t.local)}function i(){this.setAttribute(t,e)}function o(){this.setAttributeNS(t.space,t.local,e)}function a(){var n=e.apply(this,arguments);null==n?this.removeAttribute(t):this.setAttribute(t,n)}function u(){var n=e.apply(this,arguments);null==n?this.removeAttributeNS(t.space,t.local):this.setAttributeNS(t.space,t.local,n)}if(t=f(t),arguments.length<2){var s=this.node();return t.local?s.getAttributeNS(t.space,t.local):s.getAttribute(t)}return this.each(null==e?t.local?r:n:"function"==typeof e?t.local?u:a:t.local?o:i)}function E(t){function e(n,i){var o,a=-1,u=n.length;if(--i)for(var s=2*i,c=s+1;++a<u;)(o=n[a])&&(r[s]=o._parent.__data__,r[c]=a,e(o,i));else for(;++a<u;)(o=n[a])&&(r[0]=o.__data__,r[1]=a,t.apply(o,r))}var n=this._depth,r=new Array(n);return e(this._root,n),this}function C(){return!this.node()}function M(){var t=0;return this.each(function(){++t}),t}function N(){return T(this._root,this._depth)}function T(t,e){var n,r=-1,i=t.length;if(--e){for(;++r<i;)if((n=t[r])&&(n=T(n,e)))return n}else for(;++r<i;)if(n=t[r])return n}function L(){var t=new Array(this.size()),e=-1;return this.each(function(){t[++e]=this}),t}function P(){var t=arguments[0];return t.apply(arguments[0]=this,arguments),this}function D(t){return t._root=V(t._root,t._depth)}function V(t,e){var n,r=-1,i=t.length;if(--e)for(;++r<i;)(n=t[r])&&(t[r]=V(n,e));else if(!Array.isArray(t)){for(var o=new Array(i);++r<i;)o[r]=t[r];o._parent=t._parent,t=o}return t}function B(t){function e(e,n){return e&&n?t(e.__data__,n.__data__):!e-!n}function n(t,r){if(--r)for(var i,o=-1,a=t.length;++o<a;)(i=t[o])&&n(i,r);else t.sort(e)}return t||(t=R),n(D(this),this._depth),this.order()}function R(t,e){return e>t?-1:t>e?1:t>=e?0:NaN}function q(){return X(this._root,this._depth),this}function X(t,e){var n,r,i=t.length;if(--e)for(;--i>=0;)(n=t[i])&&X(n,e);else for(r=t[--i];--i>=0;)(n=t[i])&&(r&&r!==n.nextSibling&&r.parentNode.insertBefore(n,r),r=n)}function $(t){return new W(z(D(t),t._depth),t._depth)}function z(t,e){var n,r=-1,i=t.length,o=new Array(i);if(--e)for(;++r<i;)(n=t[r])&&(o[r]=z(n,e));return o._parent=t._parent,o}function I(){return this._exit||(this._exit=$(this))}function O(){return this._enter||(this._enter=$(this),this._enter._update=this),this._enter}function Y(t){return function(){return t}}function k(t,e){function n(e,r,i,o){var a,u,l=-1;if(o--){var h=2*o,f=h+1;for(a=e.length;++l<a;)(u=e[l])&&(s[h]=u._parent.__data__,s[f]=l,n(u,r[l],i[l],o))}else{var p,_=0;for(c(e,r,i,t.apply(e._parent,s)),a=e.length;++l<a;)if(p=r[l]){for(l>=_&&(_=l+1);!(u=e[_])&&++_<a;);p._next=u||null}}}function r(t,e,n,r){var i,o=0,a=t.length,u=r.length,s=Math.min(a,u);for(e.length=0,e.length=u,n.length=0,n.length=a;s>o;++o)(i=t[o])?i.__data__=r[o]:e[o]=new G(t._parent,r[o]);for(;u>o;++o)e[o]=new G(t._parent,r[o]);for(;a>o;++o)(i=t[o])&&(n[o]=t[o]);t.length=u}function i(t,n,r,i){var o,a,u,c=i.length,l=t.length,h={},f=new Array(2).concat(s),p=new Array(l);for(n.length=0,n.length=c,r.length=0,r.length=l,o=0;l>o;++o)(a=t[o])&&(f[0]=a.__data__,f[1]=o,p[o]=u=ut+e.apply(a,f),h[u]?r[o]=a:h[u]=a);for(t.length=0,t.length=c,o=0;c>o;++o)f[0]=i[o],f[1]=o,u=ut+e.apply(t._parent,f),(a=h[u])?a!==!0&&(t[o]=a,a.__data__=i[o]):n[o]=new G(t._parent,i[o]),h[u]=!0;for(o=0;l>o;++o)(a=h[p[o]])!==!0&&(r[o]=a)}if(!t){var o=new Array(this.size()),a=-1;return this.each(function(t){o[++a]=t}),o}var u=this._depth-1,s=new Array(2*u),c=e?i:r,l=this.enter(),h=this.exit();return"function"!=typeof t&&(t=Y(t)),n(this._root,l._root,h._root,u),this}function G(t,e){this.ownerDocument=t.ownerDocument,this.namespaceURI=t.namespaceURI,this._next=null,this._parent=t,this.__data__=e}function H(t){function e(n,i){var o,a,u=-1,s=n.length;if(--i){var c=2*i,l=c+1;for(a=new Array(s);++u<s;)(o=n[u])&&(r[c]=o._parent.__data__,r[l]=u,a[u]=e(o,i))}else for(a=[];++u<s;)(o=n[u])&&(r[0]=o.__data__,r[1]=u,t.apply(o,r)&&a.push(o));return a._parent=n._parent,a}var n=this._depth,r=new Array(2*n);return"function"!=typeof t&&(t=st(t)),new W(e(this._root,n),n)}function U(t){function e(n,i){var o,a,u=-1,s=n.length,c=new Array(s);if(--i)for(var l=2*i,h=l+1;++u<s;)(o=n[u])&&(r[l]=o._parent.__data__,r[h]=u,c[u]=e(o,i));else for(;++u<s;)(o=n[u])&&(r[0]=o.__data__,r[1]=u,c[u]=a=t.apply(o,r),a._parent=o);return c._parent=n._parent,c}var n=this._depth,r=new Array(2*n);return"function"!=typeof t&&(t=j(t)),new W(e(this._root,n),n+1)}function j(t){return function(){return this.querySelectorAll(t)}}function K(t){function e(n,i,o){var a,u,s=-1,c=n.length,l=new Array(c);if(--o)for(var h=2*o,f=h+1;++s<c;)(a=n[s])&&(r[h]=a._parent.__data__,r[f]=s,l[s]=e(a,i&&i[s],o));else for(;++s<c;)(a=n[s])&&(r[0]=a.__data__,r[1]=s,(u=t.apply(a,r))&&("__data__"in a&&(u.__data__=a.__data__),i&&(i[s]=u,delete n[s]),l[s]=u));return l._parent=n._parent,l}var n=this._depth,r=new Array(2*n);return"function"!=typeof t&&(t=p(t)),new W(e(this._root,this._update&&this._update._root,n),n)}function W(t,e){this._root=t,this._depth=e,this._enter=this._update=this._exit=null}function F(){return new W([document.documentElement],1)}function J(t){return new W(["string"==typeof t?document.querySelector(t):t],1)}function Q(t,e){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var r=n.createSVGPoint();if(0>ht){var i=defaultView(t);if(i.scrollX||i.scrollY){n=J(i.document.body).append("svg").style({position:"absolute",top:0,left:0,margin:0,padding:0,border:"none"},"important");var o=n.node().getScreenCTM();ht=!(o.f||o.e),n.remove()}}return ht?(r.x=e.pageX,r.y=e.pageY):(r.x=e.clientX,r.y=e.clientY),r=r.matrixTransform(t.getScreenCTM().inverse()),[r.x,r.y]}var a=t.getBoundingClientRect();return[e.clientX-a.left-t.clientLeft,e.clientY-a.top-t.clientTop]}function Z(t,e){return arguments.length<2&&(e=a()),e.changedTouches&&(e=e.changedTouches[0]),Q(t,e)}function tt(t){return new W("string"==typeof t?document.querySelectorAll(t):t,1)}function et(t,e,n){arguments.length<3&&(n=e,e=a().changedTouches);for(var r,i=0,o=e?e.length:0;o>i;++i)if((r=e[i]).identifier===n)return Q(t,r);return null}function nt(t,e){arguments.length<2&&(e=a().touches);for(var n=0,r=e?e.length:0,i=new Array(r);r>n;++n)i[n]=Q(t,e[n]);return i}var rt=/[\\\^\$\*\+\?\|\[\]\(\)\.\{\}]/g,it={};if(t.event=null,"undefined"!=typeof document){var ot=document.documentElement;"onmouseenter"in ot||(it={mouseenter:"mouseover",mouseleave:"mouseout"})}var at={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/"},ut="$";G.prototype={appendChild:function(t){return this._parent.insertBefore(t,this._next)},insertBefore:function(t,e){return this._parent.insertBefore(t,e||this._next)}};var st=function(t){return function(){return this.matches(t)}};if("undefined"!=typeof document){var ct=document.documentElement;if(!ct.matches){var lt=ct.webkitMatchesSelector||ct.msMatchesSelector||ct.mozMatchesSelector||ct.oMatchesSelector;st=function(t){return function(){return lt.call(this,t)}}}}W.prototype=F.prototype={select:K,selectAll:U,filter:H,data:k,enter:O,exit:I,order:q,sort:B,call:P,nodes:L,node:N,size:M,empty:C,each:E,attr:S,style:b,property:x,classed:v,text:m,html:g,append:_,remove:h,datum:l,on:n,dispatch:s};var ht="undefined"!=typeof navigator&&/WebKit/.test(navigator.userAgent)?-1:0,ft="0.5.0";t.version=ft,t.mouse=Z,t.namespace=f,t.namespaces=at,t.requote=e,t.select=J,t.selectAll=tt,t.selection=F,t.touch=et,t.touches=nt});
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define("d3-selection",["exports"],e):e(t.d3_selection={})}(this,function(t){"use strict";function e(t){return t.replace(rt,"\\$&")}function n(t,n,a){function u(){for(var e=p,o=arguments.length>>1,u=new Array(o);--o>=0;)e=e[arguments[(o<<1)+1]],u[o]=o?e._parent:e;var c=r(n,u,arguments);l&&(c=i(c)),s.call(this),this.addEventListener(t,this[f]=c,c._capture=a),c._listener=n}function s(){var e=this[f];e&&(this.removeEventListener(t,e,e._capture),delete this[f])}function c(){var n,r=new RegExp("^__on([^.]+)"+e(t)+"$");for(var i in this)if(n=i.match(r)){var o=this[i];this.removeEventListener(n[1],o,o._capture),delete this[i]}}var l,h=arguments.length,f="__on"+t,p=this._root;return 2>h?(h=this.node()[f])&&h._listener:(3>h&&(a=!1),(h=t.indexOf("."))>0&&(t=t.slice(0,h)),(l=it.hasOwnProperty(t))&&(t=it[t]),this.each(n?h?u:o:h?s:c))}function r(e,n,r){return function(i){for(var o=n.length,a=t.event;--o>=0;)r[o<<1]=n[o].__data__;t.event=i;try{e.apply(n[0],r)}finally{t.event=a}}}function i(t){return function(e){var n=e.relatedTarget;n&&(n===this||8&n.compareDocumentPosition(this))||t(e)}}function o(){}function a(){for(var e,n=t.event;e=n.sourceEvent;)n=e;return n}function u(t){return t&&(t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView)}function s(t,e){function n(){return c(this,t,e)}function r(){return c(this,t,e.apply(this,arguments))}return this.each("function"==typeof e?r:n)}function c(t,e,n){var r=u(t),i=r.CustomEvent;i?i=new i(e,n):(i=r.document.createEvent("Event"),n?(i.initEvent(e,n.bubbles,n.cancelable),i.detail=n.detail):i.initEvent(e,!1,!1)),t.dispatchEvent(i)}function l(t){return arguments.length?this.property("__data__",t):this.node().__data__}function h(){return this.each(function(){var t=this.parentNode;t&&t.removeChild(this)})}function f(t){var e=t.indexOf(":"),n=t;return e>=0&&"xmlns"!==(n=t.slice(0,e))&&(t=t.slice(e+1)),at.hasOwnProperty(n)?{space:at[n],local:t}:t}function p(t){return function(){return this.querySelector(t)}}function _(t,e){function n(){return this.appendChild(t.apply(this,arguments))}function r(){return this.insertBefore(t.apply(this,arguments),e.apply(this,arguments)||null)}return"function"!=typeof t&&(t=d(t)),this.select(arguments.length<2?n:("function"!=typeof e&&(e=p(e)),r))}function d(t){function e(){var e=this.ownerDocument,n=this.namespaceURI;return n?e.createElementNS(n,t):e.createElement(t)}function n(){return this.ownerDocument.createElementNS(t.space,t.local)}return t=f(t),t.local?n:e}function g(t){function e(){this.innerHTML=t}function n(){var e=t.apply(this,arguments);this.innerHTML=null==e?"":e}return arguments.length?(null==t&&(t=""),this.each("function"==typeof t?n:e)):this.node().innerHTML}function m(t){function e(){this.textContent=t}function n(){var e=t.apply(this,arguments);this.textContent=null==e?"":e}return arguments.length?(null==t&&(t=""),this.each("function"==typeof t?n:e)):this.node().textContent}function v(t,e){function n(){for(var n=-1;++n<i;)t[n](this,e)}function r(){for(var n=-1,r=e.apply(this,arguments);++n<i;)t[n](this,r)}t=(t+"").trim().split(/^|\s+/);var i=t.length;if(arguments.length<2){var o=this.node(),a=-1;if(e=o.classList){for(;++a<i;)if(!e.contains(t[a]))return!1}else for(e=o.getAttribute("class");++a<i;)if(!A(t[a]).test(e))return!1;return!0}return t=t.map(y),this.each("function"==typeof e?r:n)}function y(t){var e;return function(n,r){if(i=n.classList)return r?i.add(t):i.remove(t);e||(e=A(t));var i=n.getAttribute("class")||"";r?(e.lastIndex=0,e.test(i)||n.setAttribute("class",w(i+" "+t))):n.setAttribute("class",w(i.replace(e," ")))}}function w(t){return t.trim().replace(/\s+/g," ")}function A(t){return new RegExp("(?:^|\\s+)"+e(t)+"(?:\\s+|$)","g")}function x(t,e){function n(){delete this[t]}function r(){this[t]=e}function i(){var n=e.apply(this,arguments);null==n?delete this[t]:this[t]=n}return arguments.length<2?this.node()[t]:this.each(null==e?n:"function"==typeof e?i:r)}function b(t,e,n){function r(){this.style.removeProperty(t)}function i(){this.style.setProperty(t,e,n)}function o(){var r=e.apply(this,arguments);null==r?this.style.removeProperty(t):this.style.setProperty(t,r,n)}var a=arguments.length;return 2>a?u(a=this.node()).getComputedStyle(a,null).getPropertyValue(t):(3>a&&(n=""),this.each(null==e?r:"function"==typeof e?o:i))}function S(t,e){function n(){this.removeAttribute(t)}function r(){this.removeAttributeNS(t.space,t.local)}function i(){this.setAttribute(t,e)}function o(){this.setAttributeNS(t.space,t.local,e)}function a(){var n=e.apply(this,arguments);null==n?this.removeAttribute(t):this.setAttribute(t,n)}function u(){var n=e.apply(this,arguments);null==n?this.removeAttributeNS(t.space,t.local):this.setAttributeNS(t.space,t.local,n)}if(t=f(t),arguments.length<2){var s=this.node();return t.local?s.getAttributeNS(t.space,t.local):s.getAttribute(t)}return this.each(null==e?t.local?r:n:"function"==typeof e?t.local?u:a:t.local?o:i)}function E(t){function e(n,i){var o,a=-1,u=n.length;if(--i)for(var s=2*i,c=s+1;++a<u;)(o=n[a])&&(r[s]=o._parent.__data__,r[c]=a,e(o,i));else for(;++a<u;)(o=n[a])&&(r[0]=o.__data__,r[1]=a,t.apply(o,r))}var n=this._depth,r=new Array(n);return e(this._root,n),this}function C(){return!this.node()}function M(){var t=0;return this.each(function(){++t}),t}function N(){return T(this._root,this._depth)}function T(t,e){var n,r=-1,i=t.length;if(--e){for(;++r<i;)if((n=t[r])&&(n=T(n,e)))return n}else for(;++r<i;)if(n=t[r])return n}function L(){var t=new Array(this.size()),e=-1;return this.each(function(){t[++e]=this}),t}function P(){var t=arguments[0];return t.apply(arguments[0]=this,arguments),this}function q(t){return t._root=D(t._root,t._depth)}function D(t,e){var n,r=-1,i=t.length;if(--e)for(;++r<i;)(n=t[r])&&(t[r]=D(n,e));else if(!Array.isArray(t)){for(var o=new Array(i);++r<i;)o[r]=t[r];o._parent=t._parent,t=o}return t}function V(t){function e(e,n){return e&&n?t(e.__data__,n.__data__):!e-!n}function n(t,r){if(--r)for(var i,o=-1,a=t.length;++o<a;)(i=t[o])&&n(i,r);else t.sort(e)}return t||(t=B),n(q(this),this._depth),this.order()}function B(t,e){return e>t?-1:t>e?1:t>=e?0:NaN}function R(){return X(this._root,this._depth),this}function X(t,e){var n,r,i=t.length;if(--e)for(;--i>=0;)(n=t[i])&&X(n,e);else for(r=t[--i];--i>=0;)(n=t[i])&&(r&&r!==n.nextSibling&&r.parentNode.insertBefore(n,r),r=n)}function $(t){return new W(z(q(t),t._depth),t._depth)}function z(t,e){var n,r=-1,i=t.length,o=new Array(i);if(--e)for(;++r<i;)(n=t[r])&&(o[r]=z(n,e));return o._parent=t._parent,o}function I(){return this._exit||(this._exit=$(this))}function O(){return this._enter||(this._enter=$(this),this._enter._update=this),this._enter}function Y(t){return function(){return t}}function k(t,e){function n(e,r,i,o){var a,u,l=-1;if(o--){var h=2*o,f=h+1;for(a=e.length;++l<a;)(u=e[l])&&(s[h]=u._parent.__data__,s[f]=l,n(u,r[l],i[l],o))}else{var p,_=0;for(c(e,r,i,t.apply(e._parent,s)),a=e.length;++l<a;)if(p=r[l]){for(l>=_&&(_=l+1);!(u=e[_])&&++_<a;);p._next=u||null}}}function r(t,e,n,r){var i,o=0,a=t.length,u=r.length,s=Math.min(a,u);for(e.length=0,e.length=u,n.length=0,n.length=a;s>o;++o)(i=t[o])?i.__data__=r[o]:e[o]=new G(t._parent,r[o]);for(;u>o;++o)e[o]=new G(t._parent,r[o]);for(;a>o;++o)(i=t[o])&&(n[o]=t[o]);t.length=u}function i(t,n,r,i){var o,a,u,c=i.length,l=t.length,h={},f=new Array(2).concat(s),p=new Array(l);for(n.length=0,n.length=c,r.length=0,r.length=l,o=0;l>o;++o)(a=t[o])&&(f[0]=a.__data__,f[1]=o,p[o]=u=ut+e.apply(a,f),h[u]?r[o]=a:h[u]=a);for(t.length=0,t.length=c,o=0;c>o;++o)f[0]=i[o],f[1]=o,u=ut+e.apply(t._parent,f),(a=h[u])?a!==!0&&(t[o]=a,a.__data__=i[o]):n[o]=new G(t._parent,i[o]),h[u]=!0;for(o=0;l>o;++o)(a=h[p[o]])!==!0&&(r[o]=a)}if(!t){var o=new Array(this.size()),a=-1;return this.each(function(t){o[++a]=t}),o}var u=this._depth-1,s=new Array(2*u),c=e?i:r,l=this.enter(),h=this.exit();return"function"!=typeof t&&(t=Y(t)),n(this._root,l._root,h._root,u),this}function G(t,e){this.ownerDocument=t.ownerDocument,this.namespaceURI=t.namespaceURI,this._next=null,this._parent=t,this.__data__=e}function H(t){function e(n,i){var o,a,u=-1,s=n.length;if(--i){var c=2*i,l=c+1;for(a=new Array(s);++u<s;)(o=n[u])&&(r[c]=o._parent.__data__,r[l]=u,a[u]=e(o,i))}else for(a=[];++u<s;)(o=n[u])&&(r[0]=o.__data__,r[1]=u,t.apply(o,r)&&a.push(o));return a._parent=n._parent,a}var n=this._depth,r=new Array(2*n);return"function"!=typeof t&&(t=st(t)),new W(e(this._root,n),n)}function U(t){function e(n,i){var o,a,u=-1,s=n.length,c=new Array(s);if(--i)for(var l=2*i,h=l+1;++u<s;)(o=n[u])&&(r[l]=o._parent.__data__,r[h]=u,c[u]=e(o,i));else for(;++u<s;)(o=n[u])&&(r[0]=o.__data__,r[1]=u,c[u]=a=t.apply(o,r),a._parent=o);return c._parent=n._parent,c}var n=this._depth,r=new Array(2*n);return"function"!=typeof t&&(t=j(t)),new W(e(this._root,n),n+1)}function j(t){return function(){return this.querySelectorAll(t)}}function K(t){function e(n,i,o){var a,u,s=-1,c=n.length,l=new Array(c);if(--o)for(var h=2*o,f=h+1;++s<c;)(a=n[s])&&(r[h]=a._parent.__data__,r[f]=s,l[s]=e(a,i&&i[s],o));else for(;++s<c;)(a=n[s])&&(r[0]=a.__data__,r[1]=s,(u=t.apply(a,r))&&("__data__"in a&&(u.__data__=a.__data__),i&&(i[s]=u,delete n[s]),l[s]=u));return l._parent=n._parent,l}var n=this._depth,r=new Array(2*n);return"function"!=typeof t&&(t=p(t)),new W(e(this._root,this._update&&this._update._root,n),n)}function W(t,e){this._root=t,this._depth=e,this._enter=this._update=this._exit=null}function F(){return new W([document.documentElement],1)}function J(t){return new W(["string"==typeof t?document.querySelector(t):t],1)}function Q(t,e){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var r=n.createSVGPoint();if(0>ht){var i=defaultView(t);if(i.scrollX||i.scrollY){n=J(i.document.body).append("svg").style({position:"absolute",top:0,left:0,margin:0,padding:0,border:"none"},"important");var o=n.node().getScreenCTM();ht=!(o.f||o.e),n.remove()}}return ht?(r.x=e.pageX,r.y=e.pageY):(r.x=e.clientX,r.y=e.clientY),r=r.matrixTransform(t.getScreenCTM().inverse()),[r.x,r.y]}var a=t.getBoundingClientRect();return[e.clientX-a.left-t.clientLeft,e.clientY-a.top-t.clientTop]}function Z(t,e){return arguments.length<2&&(e=a()),e.changedTouches&&(e=e.changedTouches[0]),Q(t,e)}function tt(t){return new W("string"==typeof t?document.querySelectorAll(t):t,1)}function et(t,e,n){arguments.length<3&&(n=e,e=a().changedTouches);for(var r,i=0,o=e?e.length:0;o>i;++i)if((r=e[i]).identifier===n)return Q(t,r);return null}function nt(t,e){arguments.length<2&&(e=a().touches);for(var n=0,r=e?e.length:0,i=new Array(r);r>n;++n)i[n]=Q(t,e[n]);return i}var rt=/[\\\^\$\*\+\?\|\[\]\(\)\.\{\}]/g,it={};if(t.event=null,"undefined"!=typeof document){var ot=document.documentElement;"onmouseenter"in ot||(it={mouseenter:"mouseover",mouseleave:"mouseout"})}var at={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/"},ut="$";G.prototype={appendChild:function(t){return this._parent.insertBefore(t,this._next)},insertBefore:function(t,e){return this._parent.insertBefore(t,e||this._next)},querySelector:function(t){return this._parent.querySelector(t)}};var st=function(t){return function(){return this.matches(t)}};if("undefined"!=typeof document){var ct=document.documentElement;if(!ct.matches){var lt=ct.webkitMatchesSelector||ct.msMatchesSelector||ct.mozMatchesSelector||ct.oMatchesSelector;st=function(t){return function(){return lt.call(this,t)}}}}W.prototype=F.prototype={select:K,selectAll:U,filter:H,data:k,enter:O,exit:I,order:R,sort:V,call:P,nodes:L,node:N,size:M,empty:C,each:E,attr:S,style:b,property:x,classed:v,text:m,html:g,append:_,remove:h,datum:l,on:n,dispatch:s};var ht="undefined"!=typeof navigator&&/WebKit/.test(navigator.userAgent)?-1:0,ft="0.5.1";t.version=ft,t.mouse=Z,t.namespace=f,t.namespaces=at,t.requote=e,t.select=J,t.selectAll=tt,t.selection=F,t.touch=et,t.touches=nt});
{
"name": "d3-selection",
"version": "0.5.0",
"version": "0.5.1",
"description": "Data-driven DOM manipulation: select elements and join them to data.",

@@ -5,0 +5,0 @@ "keywords": [

@@ -115,5 +115,27 @@ # d3-selection

<a name="selection_filter" href="#selection_filter">#</a> <i>selection</i>.<b>filter</b>(<i>filter</i>)
Filters the selection, returning a new selection that contains only the elements for which the specified *filter* is true. The *filter* may be specified either as a function or as a selector string, such as `.foo`. If a function, it is passed the current datum `d` and index `i`, with the `this` context as the current DOM element. For example, to select every element with an odd index (relative to the zero-based index):
```js
var odd = selection.select(function(d, i) { return i % 2 === 1 ? this : null; });
```
Equivalently, using a filter function:
```js
var odd = selection.filter(function(d, i) { return i % 2 === 1; });
```
Or a filter selector (note that the `:nth-child` pseudo-class is a one-based index rather than a zero-based index):
```js
var odd = selection.filter(":nth-child(even)");
```
The returned selection may not preserve the index of the original selection, as some elements may be removed; you can use [*selection*.select](#selection_select) to preserve the index, if needed.
### Transformation
Selections expose a variety of operators to affect document content. Selection operators return the current selection, affording method chaining to apply multiple operators on a given selection concisely. For example, to see the name attribute and color style of an anchor element:
Selections expose a variety of operators to affect document content. Selection operators return the current selection, allowing the concise application of multiple operators on a given selection via method chaining. For example, to see the name attribute and color style of an anchor element:

@@ -134,3 +156,3 @@ ```js

To learn selections experientially, try selecting elements by writing code into your browser’s developer console! (In Chrome, open the console with ⌥⌘J.) Inspect the returned selection to see which elements are selected and how they are grouped. Apply operators to the selection and see how the page content changes.
To learn selections experientially, go to [d3js.org](https://d3js.org) and try selecting elements in your browser’s developer console! (In Chrome, open the console with ⌥⌘J.) Inspect the returned selection to see which elements are selected and how they are grouped. Apply operators to the selection and see how the page content changes.

@@ -179,3 +201,3 @@ <a name="selection_attr" href="#selection_attr">#</a> <i>selection</i>.<b>attr</b>(<i>name</i>[, <i>value</i>])

The text operator is based on the [textContent](http://www.w3.org/TR/DOM-Level-3-Core/core.html#Node3-textContent "http://www.w3.org/TR/DOM-Level-3-Core/core.html#Node3-textContent") property; setting the text content will replace any existing child elements.
The text operator is based on the [textContent](http://www.w3.org/TR/DOM-Level-3-Core/core.html#Node3-textContent) property; setting the text content will replace any existing child elements.

@@ -188,3 +210,3 @@ If a *value* is specified, sets the text content to the specified value on all selected elements. If the *value* is a constant, then all elements are given the same text content; otherwise, if the *value* is a function, then the function is evaluated for each selected element (in order), being passed the current datum *d* and the current index *i*, with the `this` context as the current DOM element. The function’s return value is then used to set each element’s text content. A null value will clear the content.

The html operator is based on the [innerHTML](http://dev.w3.org/html5/spec-LC/apis-in-html-documents.html#innerhtml "http://dev.w3.org/html5/spec-LC/apis-in-html-documents.html#innerhtml") property; setting the inner HTML will replace any existing child elements. Also, you may prefer to use [*selection*.append](#selection_append) to create HTML content in a data-driven way; this operator is intended for when you want a little bit of HTML, say for rich formatting.
The html operator is based on the [innerHTML](http://dev.w3.org/html5/spec-LC/apis-in-html-documents.html#innerhtml) property; setting the inner HTML will replace any existing child elements. Also, you may prefer to use [*selection*.append](#selection_append) to create HTML content in a data-driven way; this operator is intended for when you want a little bit of HTML, say for rich formatting.

@@ -223,2 +245,14 @@ If a *value* is specified, sets the inner HTML to the specified value on all selected elements. If the *value* is a constant, then all elements are given the same inner HTML; otherwise, if the *value* is a function, then the function is evaluated for each selected element (in order), being passed the current datum *d* and the current index *i*, with the `this` context as the current DOM element. The function’s return value is then used to set each element’s inner HTML. A null value will clear the content.

<a name="selection_sort" href="#selection_sort">#</a> <i>selection</i>.<b>sort</b>(<i>comparator</i>)
Sorts the selected elements according to the *comparator* function, and then re-inserts the document elements to match the resulting order. Returns this selection.
The comparator function, which defaults to [ascending](https://github.com/d3/d3-array#ascending), is passed two elements’ data *a* and *b* to compare. It should return either a negative, positive, or zero value. If negative, then *a* should be before *b*; if positive, then *a* should be after *b*; otherwise, *a* and *b* are considered equal and the order is arbitrary.
Note that sorting is not guaranteed to be stable; however, it is guaranteed to have the same behavior as your browser’s built-in [sort](https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/sort) method on arrays.
<a name="selection_order" href="#selection_order">#</a> <i>selection</i>.<b>order</b>()
Re-inserts elements into the document such that the document order matches the selection order. This is equivalent to calling [*selection*.sort](#selection_sort) if the data is already sorted, but much faster.
### Data

@@ -258,8 +292,8 @@

```html
<div id="Ford"></div>
<div id="Jarrah"></div>
<div id="Kwon"></div>
<div id="Locke"></div>
<div id="Reyes"></div>
<div id="Ford"></div>
<div id="Jarrah"></div>
<div id="Shephard"></div>
<div id="Kwon"></div>
```

@@ -281,3 +315,4 @@

d3.selectAll("div")
.data(data, function(d) { return d ? d.name : this.id; });
.data(data, function(d) { return d ? d.name : this.id; })
.text(function(d) { return d.number; });
```

@@ -287,11 +322,11 @@

The *update* and *enter* selections are returned in data order, while the *exit* selection is in document order (at the time that the selection was queried). If a key function is specified, the order of elements in this selection may change. However, the elements are not automatically reordered in the DOM; use [*selection*.order](#order) or [*selection*.sort](#sort) as needed. For a more detailed example of how the key function affects the data join, see the tutorial [A Bar Chart, Part 2](http://bost.ocks.org/mike/bar/2/).
The *update* and *enter* selections are returned in data order, while the *exit* selection preserves the order prior to the data join. If a key function is specified, the order of elements in the selection may not match their order in the document; use [*selection*.order](#order) or [*selection*.sort](#sort) as needed. For more on how the key function affects the join, see [A Bar Chart, Part 2](http://bost.ocks.org/mike/bar/2/).
If *data* is not specified, then this method returns the array of data the selected elements.
If *data* is not specified, this method returns the array of data for the selected elements.
Note: this method cannot be used to clear previously-bound data; use [*selection*.datum](#selection_datum) instead.
This method cannot be used to clear bound data; use [*selection*.datum](#selection_datum) instead.
<a name="selection_enter" href="#selection_enter">#</a> <i>selection</i>.<b>enter</b>()
Returns the enter selection: placeholder nodes for each datum for which there was no corresponding DOM element in the selection. The enter selection is always empty until the selection is joined to data by [*selection*.data](#selection_data). For example, to create new DIV elements corresponding to an array of numbers:
Returns the enter selection: placeholder nodes for each datum that had no corresponding DOM element in the selection. The enter selection is always empty until the selection is joined to data by [*selection*.data](#selection_data). The enter selection is typically used to create “missing” elements from new data. For example, to create DIV elements from an array of numbers:

@@ -315,3 +350,3 @@ ```js

The enter selection’s placeholders are conceptually pointers to the parent node (in this example, the document body), and the enter selection is typically only used transiently to append elements.
Conceptually, the enter selection’s placeholders are pointers to the parent element (in this example, the document body). The enter selection is typically only used transiently to append elements.

@@ -331,3 +366,3 @@ The enter selection **merges into the update selection** on [append](#selection_append). Rather than applying the same operators to the enter and update selections separately, apply them once to the update selection *after* entering nodes. For example:

Returns the exit selection: existing DOM elements for which no new datum was found. The exit selection is always empty until the selection is joined to data by [*selection*.data](#selection_data). For example, to update the DIV elements created above with a new array of numbers:
Returns the exit selection: existing DOM elements in the selection for which no new datum was found. The exit selection is always empty until the selection is joined to data by [*selection*.data](#selection_data). The exit selection is typically used to remove “superfluous” elements from old data. For example, to update the DIV elements created previously with a new array of numbers:

@@ -338,3 +373,3 @@ ```js

Since we specified a key function (the identity function), and the new data contains the numbers [4, 8, 16] which match existing elements, the update selection contains three DIV elements. We’ll leave those elements as-is. We can append new elements for [1, 2, 32] using the enter selection:
Since a key function was specified (as the identity function), and the new data contains the numbers [4, 8, 16] which match existing elements in the document, the update selection contains three DIV elements. We’ll leave those elements as-is. We can append new elements for [1, 2, 32] using the enter selection:

@@ -362,9 +397,9 @@ ```js

Note that the order of the DOM elements matches the order of the data. This is true because the old data’s order and the new data’s order were consistent. If the new data’s order is different, use [*selection*.order](#selection_order) to reorder the elements in the DOM.
Note that the order of the DOM elements matches the order of the data. This is because the old data’s order and the new data’s order were consistent. If the new data’s order is different, use [*selection*.order](#selection_order) to reorder the elements in the DOM. See the [General Update Pattern](http://bl.ocks.org/mbostock/3808218) example thread for more on data joins.
<a name="selection_datum" href="#selection_datum">#</a> <i>selection</i>.<b>datum</b>()
<a name="selection_datum" href="#selection_datum">#</a> <i>selection</i>.<b>datum</b>([<i>value</i>])
Gets or sets the bound data for each selected element. Unlike the [*selection*.data](#selection_data) method, this method does not compute a join (and thus does not affect the enter and exit selections).
Gets or sets the bound data for each selected element. Unlike [*selection*.data](#selection_data), this method does not compute a join and thus does not affect indexes or the enter and exit selections.
If a *value* is specified, sets the element’s bound data to the specified value on all selected elements. If the *value* is a constant, all elements are given the same data; otherwise, if the *value* is a function, then the function is evaluated for each selected element, being passed the previous datum `d` and the current index `i`, with the `this` context as the current DOM element. The function is then used to set each element’s data. A null value will delete the bound data. This operator has no effect on the index.
If a *value* is specified, sets the element’s bound data to the specified value on all selected elements. If the *value* is a constant, all elements are given the same datum; otherwise, if the *value* is a function, then the function is evaluated for each selected element, being passed the previous datum `d` and the current index `i`, with the `this` context as the current DOM element. The function is then used to set each element’s data. A null value will delete the bound data.

@@ -388,105 +423,124 @@ If a *value* is not specified, returns the bound datum for the first (non-null) element in the selection. This is generally useful only if you know the selection contains exactly one element.

<a name="selection_filter" href="#selection_filter">#</a> <i>selection</i>.<b>filter</b>(*selector*)
### Events
Filters the selection, returning a new selection that contains only the elements for which the specified *selector* is true. The *selector* may be specified either as a function or as a selector string, such as `.foo`. If a function, it is passed the current datum `d` and index `i`, with the `this` context as the current DOM element. Note that the returned selection *may not* preserve the index of the original selection in the returned selection, as some elements may be removed; you can use [*selection*.select](#selection_select) to preserve the index, if needed.
For interaction, selections allow listening for and dispatching of events.
For example, to select every element with an odd index (relative to the zero-based index):
<a name="selection_on" href="#selection_on">#</a> <i>selection</i>.<b>on</b>(<i>type</i>[, <i>listener</i>[, <i>capture</i>]])
```js
var odd = selection.select(function(d, i) { return i % 2 === 1 ? this : null; });
```
Adds or removes a *listener* to each selected element for the specified event *type*. The *type* is a string event type name, such as `click`, `mouseover`, or `submit`. (Any [DOM event type](https://developer.mozilla.org/en-US/docs/Web/Events#Standard_events) supported by your browser may be used.) The *listener* is invoked in the same manner as other operator functions, being passed the current datum *d* and index *i*, with the `this` context as the current DOM element. Listeners always see the latest datum for their element, but the index is a property of the selection and is fixed when the listener is assigned; to update the index, re-assign the listener. To access the current event within a listener, use [d3.event](#event).
Equivalently, using a filter function:
If an event listener was already registered for the same *type* on a selected element, the existing listener is removed before the new listener is added. To register multiple listeners for a given type, the type may be followed by an optional namespace, such as `click.foo` and `click.bar`. To remove a listener, pass null as the *listener*. To remove all listeners for a particular namespace, pass null as the *listener* and `.foo` as the *type*, where *foo* is the namespace.
```js
var odd = selection.filter(function(d, i) { return i % 2 === 1; });
```
An optional *capture* flag may be specified, which corresponds to the W3C [useCapture flag](http://www.w3.org/TR/DOM-Level-2-Events/events.html#Events-registration): “After initiating capture, all events of the specified type will be dispatched to the registered EventListener before being dispatched to any EventTargets beneath them in the tree. Events which are bubbling upward through the tree will not trigger an EventListener designated to use capture.”
Or a filter selector (note that the `:nth-child` pseudo-class is a one-based index rather than a zero-based index):
If a *listener* is not specified, returns the currently-assigned listener for the specified event *type* on the first (non-null) selected element, if any.
```js
var odd = selection.filter(":nth-child(even)");
```
<a name="selection_dispatch" href="#selection_dispatch">#</a> <i>selection</i>.<b>dispatch</b>(<i>type</i>[, <i>parameters</i>])
<a name="selection_sort" href="#selection_sort">#</a> <i>selection</i>.<b>sort</b>()
Dispatches a [custom event](http://www.w3.org/TR/dom/#interface-customevent) of the specified *type* to each selected element. An optional *parameters* map may be specified to set additional properties of the event: bubbles, cancelable, and detail. If *parameters* is a function, it will be invoked in the same manner as other operator functions, being passed the current datum `d` and index `i`, with the `this` context as the current DOM element. It must then return the parameters map for the current element.
Sorts the selected elements according to the *comparator* function, and then re-inserts the document elements to match the resulting order. Returns this selection.
<a name="event" href="#event">#</a> d3.<b>event</b>
The comparator function, which defaults to [ascending](https://github.com/d3/d3-array#ascending), is passed two elements’ data *a* and *b* to compare. It should return either a negative, positive, or zero value. If negative, then *a* should be before *b*; if positive, then *a* should be after *b*; otherwise, *a* and *b* are considered equal and the order is arbitrary.
The current [event](https://developer.mozilla.org/en-US/docs/DOM/event), if any. This is set during the invocation of an event listener, and is reset after the listener terminates. Use this to access standard event fields such as event.timeStamp, and methods such as event.preventDefault.
Note that sorting is not guaranteed to be stable; however, it is guaranteed to have the same behavior as your browser’s built-in [sort](https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/sort "https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/sort") method on arrays.
While you can use the native [event.pageX](https://developer.mozilla.org/en/DOM/event.pageX) and [event.pageY](https://developer.mozilla.org/en/DOM/event.pageY), it is often more convenient to transform the event position to the local coordinate system of the container that received the event using [d3.mouse](#mouse), [d3.touch](#touch) or [d3.touches](#touches).
<a name="selection_order" href="#selection_order">#</a> <i>selection</i>.<b>order</b>()
<a name="mouse" href="#mouse">#</a> d3.<b>mouse</b>(<i>container</i>)
Re-inserts elements into the document such that the document order matches the selection order. This is equivalent to calling [*selection*.sort](#selection_sort) if the data is already sorted, but much faster.
Returns the *x* and *y* coordinates of the [current event](#event) relative to the specified *container*. The container may be an HTML or SVG container element, such as a [G element](http://www.w3.org/TR/SVG/struct.html#Groups) or an [SVG element](http://www.w3.org/TR/SVG/struct.html#SVGElement). The coordinates are returned as a two-element array of numbers [*x*, *y*].
### Events
<a name="touch" href="#touch">#</a> d3.<b>touch</b>(<i>container</i>[, <i>touches</i>], <i>identifier</i>)
<a name="selection_on" href="#selection_on">#</a> <i>selection</i>.<b>on</b>()
Returns the *x* and *y* coordinates of the touch with the specified *identifier* associated with the [current event](#event) relative to the specified *container*. The container may be an HTML or SVG container element, such as a [G element](http://www.w3.org/TR/SVG/struct.html#Groups) or an [SVG element](http://www.w3.org/TR/SVG/struct.html#SVGElement). The coordinates are returned as an array of two-element arrays of numbers \[\[*x1*, *y1*], [*x2*, *y2*], …\]. If there is no touch with the specified identifier in *touches*, returns null; this can be useful for ignoring touchmove events where the only some touches have moved. If *touches* is not specified, it defaults to the current event’s [changedTouches](http://developer.apple.com/library/safari/documentation/UserExperience/Reference/TouchEventClassReference/TouchEvent/TouchEvent.html#//apple_ref/javascript/instp/TouchEvent/changedTouches) property.
<a name="touches" href="#touches">#</a> d3.<b>touches</b>(<i>container</i>[, <i>touches</i>])
<a name="selection_dispatch" href="#selection_dispatch">#</a> <i>selection</i>.<b>dispatch</b>()
Returns the *x* and *y* coordinates of the touches associated with the [current event](#event) relative to the specified *container*. The container may be an HTML or SVG container element, such as a [G element](http://www.w3.org/TR/SVG/struct.html#Groups) or an [SVG element](http://www.w3.org/TR/SVG/struct.html#SVGElement). The coordinates are returned as an array of two-element arrays of numbers \[\[*x1*, *y1*], [*x2*, *y2*], …\]. If *touches* is not specified, it defaults to the current event’s [touches](http://developer.apple.com/library/safari/documentation/UserExperience/Reference/TouchEventClassReference/TouchEvent/TouchEvent.html#//apple_ref/javascript/instp/TouchEvent/touches) property.
### Control
<a name="event" href="#event">#</a> d3.<b>event</b>
For advanced usage, selections provide operators for custom control flow.
<a name="selection_each" href="#selection_each">#</a> <i>selection</i>.<b>each</b>(<i>function</i>)
<a name="mouse" href="#mouse">#</a> d3.<b>mouse</b>()
Invokes the specified *function* for each selected element, passing in the current datum `d` and index `i`, with the `this` context of the current DOM element. This operator is used internally by most other operators, and can be used to invoke arbitrary code for each selected element.
<a name="selection_call" href="#selection_call">#</a> <i>selection</i>.<b>call</b>(<i>selection</i>[, <i>arguments…</i>])
<a name="touch" href="#touch">#</a> d3.<b>touch</b>()
Invokes the specified *function* (once), passing in the current selection along with any optional *arguments*, and returns the current selection. The call operator is identical to invoking a function by hand, but it facilitates method chaining. For example, to set several attributes in a reusable function:
```javascript
function name(selection, first, last) {
selection
.attr("first-name", first)
.attr("last-name", last);
}
```
<a name="touches" href="#touches">#</a> d3.<b>touches</b>()
Now, we can say this:
```javascript
name(d3.selectAll("div"), "John", "Snow");
```
Or equivalently:
### Control
```javascript
d3.selectAll("div").call(name, "John", "Snow");
```
For advanced usage, D3 has a few additional operators for custom control flow.
The `this` context of the called function is also the current selection. This is slightly redundant with the first argument, which we might fix in the future.
<a name="selection_each" href="#selection_each">#</a> <i>selection</i>.<b>each</b>()
<a name="selection_call" href="#selection_call">#</a> <i>selection</i>.<b>call</b>()
<a name="selection_empty" href="#selection_empty">#</a> <i>selection</i>.<b>empty</b>()
Returns true if this selection is empty. A selection is empty if it contains no elements, or all elements are null.
<a name="selection_nodes" href="#selection_nodes">#</a> <i>selection</i>.<b>nodes</b>()
Returns an array of all (non-null) elements in this selection.
<a name="selection_node" href="#selection_node">#</a> <i>selection</i>.<b>node</b>()
Returns the first (non-null) element in this selection. If the selection is empty, returns null.
<a name="selection_size" href="#selection_size">#</a> <i>selection</i>.<b>size</b>()
Returns the total number of elements in this selection.
### Namespaces
XML namespaces are fun! Right? Fortunately you can mostly ignore them.
<a name="namespace" href="#namespace">#</a> d3.<b>namespace</b>()
<a name="namespace" href="#namespace">#</a> d3.<b>namespace</b>(<i>name</i>)
Qualifies the specified *name*, which may or may not have a namespace prefix. If the name contains a colon (`:`), the substring before the colon is interpreted as the namespace prefix, which must be registered in [d3.namespaces](#namespaces). Returns an object `space` and `local` attributes describing the full namespace URL and the local name. For example:
<a name="namespaces" href="#namespaces">#</a> d3.<b>namespaces</b>()
```js
d3.namespace("svg:text"); // {space: "http://www.w3.org/2000/svg", local: "text"}
```
If the name does not contain a colon, this function merely returns the input name.
<a name="requote" href="#requote">#</a> d3.<b>requote</b>()
<a name="namespaces" href="#namespaces">#</a> d3.<b>namespaces</b>
The map of registered namespace prefixes. The default value is:
```js
{
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/"
}
```
Additional prefixes may be assigned as needed to create elements or attributes in other namespaces.
<a name="requote" href="#requote">#</a> d3.<b>requote</b>(<i>string</i>)
Returns a quoted (escaped) version of the specified *string* that may be safely embedded within a regular expression as a string literal. For example:
```js
d3.requote("[]"); // "\[\]"
```

@@ -182,3 +182,4 @@ import constant from "./constant";

appendChild: function(child) { return this._parent.insertBefore(child, this._next); },
insertBefore: function(child, next) { return this._parent.insertBefore(child, next || this._next); }
insertBefore: function(child, next) { return this._parent.insertBefore(child, next || this._next); },
querySelector: function(selector) { return this._parent.querySelector(selector); }
};
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc