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.7.3 to 0.8.0

src/local.js

65

build/d3-selection.js

@@ -0,9 +1,8 @@

// https://d3js.org/d3-selection/ Version 0.8.0. Copyright 2016 Mike Bostock.
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(factory((global.d3_selection = global.d3_selection || {})));
(factory((global.d3 = global.d3 || {})));
}(this, function (exports) { 'use strict';
var version = "0.7.3";
var xhtml = "http://www.w3.org/1999/xhtml";

@@ -48,2 +47,30 @@

var nextId = 0;
function local() {
return new Local;
}
function Local() {
this._ = "@" + (++nextId).toString(36);
}
Local.prototype = local.prototype = {
constructor: Local,
get: function(node) {
var id = this._;
while (!(id in node)) if (!(node = node.parentNode)) return;
return node[id];
},
set: function(node, value) {
return node[this._] = value;
},
remove: function(node) {
return this._ in node && delete node[this._];
},
toString: function() {
return this._;
}
};
var matcher = function(selector) {

@@ -778,14 +805,9 @@ return function() {

function append(create) {
return function() {
function selection_append(name) {
var create = typeof name === "function" ? name : creator(name);
return this.select(function() {
return this.appendChild(create.apply(this, arguments));
};
});
}
function insert(create, select) {
return function() {
return this.insertBefore(create.apply(this, arguments), select.apply(this, arguments) || null);
};
}
function constantNull() {

@@ -795,10 +817,8 @@ return null;

function selection_append(name, before) {
var create = typeof name === "function" ? name : creator(name);
return this.select(arguments.length < 2
? append(create)
: insert(create, before == null
? constantNull : typeof before === "function"
? before
: selector(before)));
function selection_insert(name, before) {
var create = typeof name === "function" ? name : creator(name),
select = before == null ? constantNull : typeof before === "function" ? before : selector(before);
return this.select(function() {
return this.insertBefore(create.apply(this, arguments), select.apply(this, arguments) || null);
});
}

@@ -891,2 +911,3 @@

append: selection_append,
insert: selection_insert,
remove: selection_remove,

@@ -932,4 +953,4 @@ datum: selection_datum,

exports.version = version;
exports.creator = creator;
exports.local = local;
exports.matcher = matcher$1;

@@ -949,2 +970,4 @@ exports.mouse = mouse;

Object.defineProperty(exports, '__esModule', { value: true });
}));

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

!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n(t.d3_selection=t.d3_selection||{})}(this,function(t){"use strict";function n(t){var n=t+="",e=n.indexOf(":");return e>=0&&"xmlns"!==(n=t.slice(0,e))&&(t=t.slice(e+1)),It.hasOwnProperty(n)?{space:It[n],local:t}:t}function e(t){return function(){var n=this.ownerDocument,e=this.namespaceURI;return e===Ht&&n.documentElement.namespaceURI===Ht?n.createElement(t):n.createElementNS(e,t)}}function r(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function i(t){var i=n(t);return(i.local?r:e)(i)}function o(t,n,e){return t=u(t,n,e),function(n){var e=n.relatedTarget;e&&(e===this||8&e.compareDocumentPosition(this))||t.call(this,n)}}function u(n,e,r){return function(i){var o=t.event;t.event=i;try{n.call(this,this.__data__,e,r)}finally{t.event=o}}}function c(t){return t.trim().split(/^|\s+/).map(function(t){var n="",e=t.indexOf(".");return e>=0&&(n=t.slice(e+1),t=t.slice(0,e)),{type:t,name:n}})}function s(t){return function(){var n=this.__on;if(n){for(var e,r=0,i=-1,o=n.length;o>r;++r)e=n[r],t.type&&e.type!==t.type||e.name!==t.name?n[++i]=e:this.removeEventListener(e.type,e.listener,e.capture);++i?n.length=i:delete this.__on}}}function a(t,n,e){var r=Xt.hasOwnProperty(t.type)?o:u;return function(i,o,u){var c,s=this.__on,a=r(n,o,u);if(s)for(var l=0,f=s.length;f>l;++l)if((c=s[l]).type===t.type&&c.name===t.name)return this.removeEventListener(c.type,c.listener,c.capture),this.addEventListener(c.type,c.listener=a,c.capture=e),void(c.value=n);this.addEventListener(t.type,a,e),c={type:t.type,name:t.name,value:n,listener:a,capture:e},s?s.push(c):this.__on=[c]}}function l(t,n,e){var r,i,o=c(t+""),u=o.length;{if(!(arguments.length<2)){for(l=n?a:s,null==e&&(e=!1),r=0;u>r;++r)this.each(l(o[r],n,e));return this}var l=this.node().__on;if(l)for(var f,h=0,p=l.length;p>h;++h)for(r=0,f=l[h];u>r;++r)if((i=o[r]).type===f.type&&i.name===f.name)return f.value}}function f(n,e,r,i){var o=t.event;n.sourceEvent=t.event,t.event=n;try{return e.apply(r,i)}finally{t.event=o}}function h(){for(var n,e=t.event;n=e.sourceEvent;)e=n;return e}function p(t,n){var e=t.ownerSVGElement||t;if(e.createSVGPoint){var r=e.createSVGPoint();return r.x=n.clientX,r.y=n.clientY,r=r.matrixTransform(t.getScreenCTM().inverse()),[r.x,r.y]}var i=t.getBoundingClientRect();return[n.clientX-i.left-t.clientLeft,n.clientY-i.top-t.clientTop]}function _(t){var n=h();return n.changedTouches&&(n=n.changedTouches[0]),p(t,n)}function v(t){return function(){return this.querySelector(t)}}function d(t){"function"!=typeof t&&(t=v(t));for(var n=this._groups,e=n.length,r=new Array(e),i=0;e>i;++i)for(var o,u,c=n[i],s=c.length,a=r[i]=new Array(s),l=0;s>l;++l)(o=c[l])&&(u=t.call(o,o.__data__,l,c))&&("__data__"in o&&(u.__data__=o.__data__),a[l]=u);return new qt(r,this._parents)}function m(t){return function(){return this.querySelectorAll(t)}}function y(t){"function"!=typeof t&&(t=m(t));for(var n=this._groups,e=n.length,r=[],i=[],o=0;e>o;++o)for(var u,c=n[o],s=c.length,a=0;s>a;++a)(u=c[a])&&(r.push(t.call(u,u.__data__,a,c)),i.push(u));return new qt(r,i)}function g(t){"function"!=typeof t&&(t=Gt(t));for(var n=this._groups,e=n.length,r=new Array(e),i=0;e>i;++i)for(var o,u=n[i],c=u.length,s=r[i]=new Array(c),a=0;c>a;++a)(o=u[a])&&t.call(o,o.__data__,a,u)&&(s[a]=o);return new qt(r,this._parents)}function w(t){return function(){return t}}function A(t,n,e,r,i,o){for(var u,c=0,s=n.length,a=o.length;a>c;++c)(u=n[c])?(u.__data__=o[c],r[c]=u):e[c]=new E(t,o[c]);for(;s>c;++c)(u=n[c])&&(i[c]=u)}function x(t,n,e,r,i,o,u){var c,s,a,l={},f=n.length,h=o.length,p=new Array(f);for(c=0;f>c;++c)(s=n[c])&&(p[c]=a=$t+u.call(s,s.__data__,c,n),a in l?i[c]=s:l[a]=s);for(c=0;h>c;++c)a=$t+u.call(t,o[c],c,o),(s=l[a])?(r[c]=s,s.__data__=o[c],l[a]=null):e[c]=new E(t,o[c]);for(c=0;f>c;++c)(s=n[c])&&l[p[c]]===s&&(i[c]=s)}function S(t,n){if(!t)return p=new Array(this.size()),a=-1,this.each(function(t){p[++a]=t}),p;var e=n?x:A,r=this._parents,i=this._groups;"function"!=typeof t&&(t=w(t));for(var o=i.length,u=new Array(o),c=new Array(o),s=new Array(o),a=0;o>a;++a){var l=r[a],f=i[a],h=f.length,p=t.call(l,l&&l.__data__,a,r),_=p.length,v=c[a]=new Array(_),d=u[a]=new Array(_),m=s[a]=new Array(h);e(l,f,v,d,m,p,n);for(var y,g,S=0,E=0;_>S;++S)if(y=v[S]){for(S>=E&&(E=S+1);!(g=d[E])&&++E<_;);y._next=g||null}}return u=new qt(u,r),u._enter=c,u._exit=s,u}function E(t,n){this.ownerDocument=t.ownerDocument,this.namespaceURI=t.namespaceURI,this._next=null,this._parent=t,this.__data__=n}function b(t){return new Array(t.length)}function N(){return new qt(this._enter||this._groups.map(b),this._parents)}function C(){return new qt(this._exit||this._groups.map(b),this._parents)}function L(t){for(var n=this._groups,e=t._groups,r=n.length,i=e.length,o=Math.min(r,i),u=new Array(r),c=0;o>c;++c)for(var s,a=n[c],l=e[c],f=a.length,h=u[c]=new Array(f),p=0;f>p;++p)(s=a[p]||l[p])&&(h[p]=s);for(;r>c;++c)u[c]=n[c];return new qt(u,this._parents)}function M(){for(var t=this._groups,n=-1,e=t.length;++n<e;)for(var r,i=t[n],o=i.length-1,u=i[o];--o>=0;)(r=i[o])&&(u&&u!==r.nextSibling&&u.parentNode.insertBefore(r,u),u=r);return this}function T(t){function n(n,e){return n&&e?t(n.__data__,e.__data__):!n-!e}t||(t=P);for(var e=this._groups,r=e.length,i=new Array(r),o=0;r>o;++o){for(var u,c=e[o],s=c.length,a=i[o]=new Array(s),l=0;s>l;++l)(u=c[l])&&(a[l]=u);a.sort(n)}return new qt(i,this._parents).order()}function P(t,n){return n>t?-1:t>n?1:t>=n?0:NaN}function q(){var t=arguments[0];return arguments[0]=this,t.apply(null,arguments),this}function B(){var t=new Array(this.size()),n=-1;return this.each(function(){t[++n]=this}),t}function D(){for(var t=this._groups,n=0,e=t.length;e>n;++n)for(var r=t[n],i=0,o=r.length;o>i;++i){var u=r[i];if(u)return u}return null}function O(){var t=0;return this.each(function(){++t}),t}function V(){return!this.node()}function R(t){for(var n=this._groups,e=0,r=n.length;r>e;++e)for(var i,o=n[e],u=0,c=o.length;c>u;++u)(i=o[u])&&t.call(i,i.__data__,u,o);return this}function z(t){return function(){this.removeAttribute(t)}}function H(t){return function(){this.removeAttributeNS(t.space,t.local)}}function I(t,n){return function(){this.setAttribute(t,n)}}function U(t,n){return function(){this.setAttributeNS(t.space,t.local,n)}}function j(t,n){return function(){var e=n.apply(this,arguments);null==e?this.removeAttribute(t):this.setAttribute(t,e)}}function k(t,n){return function(){var e=n.apply(this,arguments);null==e?this.removeAttributeNS(t.space,t.local):this.setAttributeNS(t.space,t.local,e)}}function G(t,e){var r=n(t);if(arguments.length<2){var i=this.node();return r.local?i.getAttributeNS(r.space,r.local):i.getAttribute(r)}return this.each((null==e?r.local?H:z:"function"==typeof e?r.local?k:j:r.local?U:I)(r,e))}function X(t){return t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView}function Y(t){return function(){this.style.removeProperty(t)}}function $(t,n,e){return function(){this.style.setProperty(t,n,e)}}function F(t,n,e){return function(){var r=n.apply(this,arguments);null==r?this.style.removeProperty(t):this.style.setProperty(t,r,e)}}function J(t,n,e){var r;return arguments.length>1?this.each((null==n?Y:"function"==typeof n?F:$)(t,n,null==e?"":e)):X(r=this.node()).getComputedStyle(r,null).getPropertyValue(t)}function K(t){return function(){delete this[t]}}function Q(t,n){return function(){this[t]=n}}function W(t,n){return function(){var e=n.apply(this,arguments);null==e?delete this[t]:this[t]=e}}function Z(t,n){return arguments.length>1?this.each((null==n?K:"function"==typeof n?W:Q)(t,n)):this.node()[t]}function tt(t){return t.trim().split(/^|\s+/)}function nt(t){return t.classList||new et(t)}function et(t){this._node=t,this._names=tt(t.getAttribute("class")||"")}function rt(t,n){for(var e=nt(t),r=-1,i=n.length;++r<i;)e.add(n[r])}function it(t,n){for(var e=nt(t),r=-1,i=n.length;++r<i;)e.remove(n[r])}function ot(t){return function(){rt(this,t)}}function ut(t){return function(){it(this,t)}}function ct(t,n){return function(){(n.apply(this,arguments)?rt:it)(this,t)}}function st(t,n){var e=tt(t+"");if(arguments.length<2){for(var r=nt(this.node()),i=-1,o=e.length;++i<o;)if(!r.contains(e[i]))return!1;return!0}return this.each(("function"==typeof n?ct:n?ot:ut)(e,n))}function at(){this.textContent=""}function lt(t){return function(){this.textContent=t}}function ft(t){return function(){var n=t.apply(this,arguments);this.textContent=null==n?"":n}}function ht(t){return arguments.length?this.each(null==t?at:("function"==typeof t?ft:lt)(t)):this.node().textContent}function pt(){this.innerHTML=""}function _t(t){return function(){this.innerHTML=t}}function vt(t){return function(){var n=t.apply(this,arguments);this.innerHTML=null==n?"":n}}function dt(t){return arguments.length?this.each(null==t?pt:("function"==typeof t?vt:_t)(t)):this.node().innerHTML}function mt(){this.nextSibling&&this.parentNode.appendChild(this)}function yt(){return this.each(mt)}function gt(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function wt(){return this.each(gt)}function At(t){return function(){return this.appendChild(t.apply(this,arguments))}}function xt(t,n){return function(){return this.insertBefore(t.apply(this,arguments),n.apply(this,arguments)||null)}}function St(){return null}function Et(t,n){var e="function"==typeof t?t:i(t);return this.select(arguments.length<2?At(e):xt(e,null==n?St:"function"==typeof n?n:v(n)))}function bt(){var t=this.parentNode;t&&t.removeChild(this)}function Nt(){return this.each(bt)}function Ct(t){return arguments.length?this.property("__data__",t):this.node().__data__}function Lt(t,n,e){var r=X(t),i=r.CustomEvent;i?i=new i(n,e):(i=r.document.createEvent("Event"),e?(i.initEvent(n,e.bubbles,e.cancelable),i.detail=e.detail):i.initEvent(n,!1,!1)),t.dispatchEvent(i)}function Mt(t,n){return function(){return Lt(this,t,n)}}function Tt(t,n){return function(){return Lt(this,t,n.apply(this,arguments))}}function Pt(t,n){return this.each(("function"==typeof n?Tt:Mt)(t,n))}function qt(t,n){this._groups=t,this._parents=n}function Bt(){return new qt([[document.documentElement]],Ft)}function Dt(t){return"string"==typeof t?new qt([[document.querySelector(t)]],[document.documentElement]):new qt([[t]],Ft)}function Ot(t){return"string"==typeof t?new qt([document.querySelectorAll(t)],[document.documentElement]):new qt([t],Ft)}function Vt(t,n,e){arguments.length<3&&(e=n,n=h().changedTouches);for(var r,i=0,o=n?n.length:0;o>i;++i)if((r=n[i]).identifier===e)return p(t,r);return null}function Rt(t,n){null==n&&(n=h().touches);for(var e=0,r=n?n.length:0,i=new Array(r);r>e;++e)i[e]=p(t,n[e]);return i}var zt="0.7.3",Ht="http://www.w3.org/1999/xhtml",It={svg:"http://www.w3.org/2000/svg",xhtml:Ht,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"},Ut=function(t){return function(){return this.matches(t)}};if("undefined"!=typeof document){var jt=document.documentElement;if(!jt.matches){var kt=jt.webkitMatchesSelector||jt.msMatchesSelector||jt.mozMatchesSelector||jt.oMatchesSelector;Ut=function(t){return function(){return kt.call(this,t)}}}}var Gt=Ut,Xt={};if(t.event=null,"undefined"!=typeof document){var Yt=document.documentElement;"onmouseenter"in Yt||(Xt={mouseenter:"mouseover",mouseleave:"mouseout"})}var $t="$";E.prototype={constructor:E,appendChild:function(t){return this._parent.insertBefore(t,this._next)},insertBefore:function(t,n){return this._parent.insertBefore(t,n)},querySelector:function(t){return this._parent.querySelector(t)},querySelectorAll:function(t){return this._parent.querySelectorAll(t)}},et.prototype={add:function(t){var n=this._names.indexOf(t);0>n&&(this._names.push(t),this._node.setAttribute("class",this._names.join(" ")))},remove:function(t){var n=this._names.indexOf(t);n>=0&&(this._names.splice(n,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}};var Ft=[null];qt.prototype=Bt.prototype={constructor:qt,select:d,selectAll:y,filter:g,data:S,enter:N,exit:C,merge:L,order:M,sort:T,call:q,nodes:B,node:D,size:O,empty:V,each:R,attr:G,style:J,property:Z,classed:st,text:ht,html:dt,raise:yt,lower:wt,append:Et,remove:Nt,datum:Ct,on:l,dispatch:Pt},t.version=zt,t.creator=i,t.matcher=Gt,t.mouse=_,t.namespace=n,t.namespaces=It,t.select=Dt,t.selectAll=Ot,t.selection=Bt,t.selector=v,t.selectorAll=m,t.touch=Vt,t.touches=Rt,t.window=X,t.customEvent=f});
// https://d3js.org/d3-selection/ Version 0.8.0. Copyright 2016 Mike Bostock.
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n(t.d3=t.d3||{})}(this,function(t){"use strict";function n(t){var n=t+="",e=n.indexOf(":");return e>=0&&"xmlns"!==(n=t.slice(0,e))&&(t=t.slice(e+1)),Ht.hasOwnProperty(n)?{space:Ht[n],local:t}:t}function e(t){return function(){var n=this.ownerDocument,e=this.namespaceURI;return e===zt&&n.documentElement.namespaceURI===zt?n.createElement(t):n.createElementNS(e,t)}}function r(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function i(t){var i=n(t);return(i.local?r:e)(i)}function o(){return new u}function u(){this._="@"+(++It).toString(36)}function c(t,n,e){return t=s(t,n,e),function(n){var e=n.relatedTarget;e&&(e===this||8&e.compareDocumentPosition(this))||t.call(this,n)}}function s(n,e,r){return function(i){var o=t.event;t.event=i;try{n.call(this,this.__data__,e,r)}finally{t.event=o}}}function a(t){return t.trim().split(/^|\s+/).map(function(t){var n="",e=t.indexOf(".");return e>=0&&(n=t.slice(e+1),t=t.slice(0,e)),{type:t,name:n}})}function l(t){return function(){var n=this.__on;if(n){for(var e,r=0,i=-1,o=n.length;o>r;++r)e=n[r],t.type&&e.type!==t.type||e.name!==t.name?n[++i]=e:this.removeEventListener(e.type,e.listener,e.capture);++i?n.length=i:delete this.__on}}}function f(t,n,e){var r=Yt.hasOwnProperty(t.type)?c:s;return function(i,o,u){var c,s=this.__on,a=r(n,o,u);if(s)for(var l=0,f=s.length;f>l;++l)if((c=s[l]).type===t.type&&c.name===t.name)return this.removeEventListener(c.type,c.listener,c.capture),this.addEventListener(c.type,c.listener=a,c.capture=e),void(c.value=n);this.addEventListener(t.type,a,e),c={type:t.type,name:t.name,value:n,listener:a,capture:e},s?s.push(c):this.__on=[c]}}function h(t,n,e){var r,i,o=a(t+""),u=o.length;{if(!(arguments.length<2)){for(c=n?f:l,null==e&&(e=!1),r=0;u>r;++r)this.each(c(o[r],n,e));return this}var c=this.node().__on;if(c)for(var s,h=0,p=c.length;p>h;++h)for(r=0,s=c[h];u>r;++r)if((i=o[r]).type===s.type&&i.name===s.name)return s.value}}function p(n,e,r,i){var o=t.event;n.sourceEvent=t.event,t.event=n;try{return e.apply(r,i)}finally{t.event=o}}function _(){for(var n,e=t.event;n=e.sourceEvent;)e=n;return e}function v(t,n){var e=t.ownerSVGElement||t;if(e.createSVGPoint){var r=e.createSVGPoint();return r.x=n.clientX,r.y=n.clientY,r=r.matrixTransform(t.getScreenCTM().inverse()),[r.x,r.y]}var i=t.getBoundingClientRect();return[n.clientX-i.left-t.clientLeft,n.clientY-i.top-t.clientTop]}function d(t){var n=_();return n.changedTouches&&(n=n.changedTouches[0]),v(t,n)}function m(t){return function(){return this.querySelector(t)}}function y(t){"function"!=typeof t&&(t=m(t));for(var n=this._groups,e=n.length,r=new Array(e),i=0;e>i;++i)for(var o,u,c=n[i],s=c.length,a=r[i]=new Array(s),l=0;s>l;++l)(o=c[l])&&(u=t.call(o,o.__data__,l,c))&&("__data__"in o&&(u.__data__=o.__data__),a[l]=u);return new Ot(r,this._parents)}function g(t){return function(){return this.querySelectorAll(t)}}function w(t){"function"!=typeof t&&(t=g(t));for(var n=this._groups,e=n.length,r=[],i=[],o=0;e>o;++o)for(var u,c=n[o],s=c.length,a=0;s>a;++a)(u=c[a])&&(r.push(t.call(u,u.__data__,a,c)),i.push(u));return new Ot(r,i)}function A(t){"function"!=typeof t&&(t=Xt(t));for(var n=this._groups,e=n.length,r=new Array(e),i=0;e>i;++i)for(var o,u=n[i],c=u.length,s=r[i]=new Array(c),a=0;c>a;++a)(o=u[a])&&t.call(o,o.__data__,a,u)&&(s[a]=o);return new Ot(r,this._parents)}function x(t){return function(){return t}}function S(t,n,e,r,i,o){for(var u,c=0,s=n.length,a=o.length;a>c;++c)(u=n[c])?(u.__data__=o[c],r[c]=u):e[c]=new N(t,o[c]);for(;s>c;++c)(u=n[c])&&(i[c]=u)}function b(t,n,e,r,i,o,u){var c,s,a,l={},f=n.length,h=o.length,p=new Array(f);for(c=0;f>c;++c)(s=n[c])&&(p[c]=a=Ft+u.call(s,s.__data__,c,n),a in l?i[c]=s:l[a]=s);for(c=0;h>c;++c)a=Ft+u.call(t,o[c],c,o),(s=l[a])?(r[c]=s,s.__data__=o[c],l[a]=null):e[c]=new N(t,o[c]);for(c=0;f>c;++c)(s=n[c])&&l[p[c]]===s&&(i[c]=s)}function E(t,n){if(!t)return p=new Array(this.size()),a=-1,this.each(function(t){p[++a]=t}),p;var e=n?b:S,r=this._parents,i=this._groups;"function"!=typeof t&&(t=x(t));for(var o=i.length,u=new Array(o),c=new Array(o),s=new Array(o),a=0;o>a;++a){var l=r[a],f=i[a],h=f.length,p=t.call(l,l&&l.__data__,a,r),_=p.length,v=c[a]=new Array(_),d=u[a]=new Array(_),m=s[a]=new Array(h);e(l,f,v,d,m,p,n);for(var y,g,w=0,A=0;_>w;++w)if(y=v[w]){for(w>=A&&(A=w+1);!(g=d[A])&&++A<_;);y._next=g||null}}return u=new Ot(u,r),u._enter=c,u._exit=s,u}function N(t,n){this.ownerDocument=t.ownerDocument,this.namespaceURI=t.namespaceURI,this._next=null,this._parent=t,this.__data__=n}function C(t){return new Array(t.length)}function M(){return new Ot(this._enter||this._groups.map(C),this._parents)}function L(){return new Ot(this._exit||this._groups.map(C),this._parents)}function P(t){for(var n=this._groups,e=t._groups,r=n.length,i=e.length,o=Math.min(r,i),u=new Array(r),c=0;o>c;++c)for(var s,a=n[c],l=e[c],f=a.length,h=u[c]=new Array(f),p=0;f>p;++p)(s=a[p]||l[p])&&(h[p]=s);for(;r>c;++c)u[c]=n[c];return new Ot(u,this._parents)}function T(){for(var t=this._groups,n=-1,e=t.length;++n<e;)for(var r,i=t[n],o=i.length-1,u=i[o];--o>=0;)(r=i[o])&&(u&&u!==r.nextSibling&&u.parentNode.insertBefore(r,u),u=r);return this}function q(t){function n(n,e){return n&&e?t(n.__data__,e.__data__):!n-!e}t||(t=O);for(var e=this._groups,r=e.length,i=new Array(r),o=0;r>o;++o){for(var u,c=e[o],s=c.length,a=i[o]=new Array(s),l=0;s>l;++l)(u=c[l])&&(a[l]=u);a.sort(n)}return new Ot(i,this._parents).order()}function O(t,n){return n>t?-1:t>n?1:t>=n?0:NaN}function B(){var t=arguments[0];return arguments[0]=this,t.apply(null,arguments),this}function D(){var t=new Array(this.size()),n=-1;return this.each(function(){t[++n]=this}),t}function V(){for(var t=this._groups,n=0,e=t.length;e>n;++n)for(var r=t[n],i=0,o=r.length;o>i;++i){var u=r[i];if(u)return u}return null}function R(){var t=0;return this.each(function(){++t}),t}function j(){return!this.node()}function z(t){for(var n=this._groups,e=0,r=n.length;r>e;++e)for(var i,o=n[e],u=0,c=o.length;c>u;++u)(i=o[u])&&t.call(i,i.__data__,u,o);return this}function H(t){return function(){this.removeAttribute(t)}}function I(t){return function(){this.removeAttributeNS(t.space,t.local)}}function U(t,n){return function(){this.setAttribute(t,n)}}function k(t,n){return function(){this.setAttributeNS(t.space,t.local,n)}}function G(t,n){return function(){var e=n.apply(this,arguments);null==e?this.removeAttribute(t):this.setAttribute(t,e)}}function X(t,n){return function(){var e=n.apply(this,arguments);null==e?this.removeAttributeNS(t.space,t.local):this.setAttributeNS(t.space,t.local,e)}}function Y(t,e){var r=n(t);if(arguments.length<2){var i=this.node();return r.local?i.getAttributeNS(r.space,r.local):i.getAttribute(r)}return this.each((null==e?r.local?I:H:"function"==typeof e?r.local?X:G:r.local?k:U)(r,e))}function $(t){return t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView}function F(t){return function(){this.style.removeProperty(t)}}function J(t,n,e){return function(){this.style.setProperty(t,n,e)}}function K(t,n,e){return function(){var r=n.apply(this,arguments);null==r?this.style.removeProperty(t):this.style.setProperty(t,r,e)}}function Q(t,n,e){var r;return arguments.length>1?this.each((null==n?F:"function"==typeof n?K:J)(t,n,null==e?"":e)):$(r=this.node()).getComputedStyle(r,null).getPropertyValue(t)}function W(t){return function(){delete this[t]}}function Z(t,n){return function(){this[t]=n}}function tt(t,n){return function(){var e=n.apply(this,arguments);null==e?delete this[t]:this[t]=e}}function nt(t,n){return arguments.length>1?this.each((null==n?W:"function"==typeof n?tt:Z)(t,n)):this.node()[t]}function et(t){return t.trim().split(/^|\s+/)}function rt(t){return t.classList||new it(t)}function it(t){this._node=t,this._names=et(t.getAttribute("class")||"")}function ot(t,n){for(var e=rt(t),r=-1,i=n.length;++r<i;)e.add(n[r])}function ut(t,n){for(var e=rt(t),r=-1,i=n.length;++r<i;)e.remove(n[r])}function ct(t){return function(){ot(this,t)}}function st(t){return function(){ut(this,t)}}function at(t,n){return function(){(n.apply(this,arguments)?ot:ut)(this,t)}}function lt(t,n){var e=et(t+"");if(arguments.length<2){for(var r=rt(this.node()),i=-1,o=e.length;++i<o;)if(!r.contains(e[i]))return!1;return!0}return this.each(("function"==typeof n?at:n?ct:st)(e,n))}function ft(){this.textContent=""}function ht(t){return function(){this.textContent=t}}function pt(t){return function(){var n=t.apply(this,arguments);this.textContent=null==n?"":n}}function _t(t){return arguments.length?this.each(null==t?ft:("function"==typeof t?pt:ht)(t)):this.node().textContent}function vt(){this.innerHTML=""}function dt(t){return function(){this.innerHTML=t}}function mt(t){return function(){var n=t.apply(this,arguments);this.innerHTML=null==n?"":n}}function yt(t){return arguments.length?this.each(null==t?vt:("function"==typeof t?mt:dt)(t)):this.node().innerHTML}function gt(){this.nextSibling&&this.parentNode.appendChild(this)}function wt(){return this.each(gt)}function At(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function xt(){return this.each(At)}function St(t){var n="function"==typeof t?t:i(t);return this.select(function(){return this.appendChild(n.apply(this,arguments))})}function bt(){return null}function Et(t,n){var e="function"==typeof t?t:i(t),r=null==n?bt:"function"==typeof n?n:m(n);return this.select(function(){return this.insertBefore(e.apply(this,arguments),r.apply(this,arguments)||null)})}function Nt(){var t=this.parentNode;t&&t.removeChild(this)}function Ct(){return this.each(Nt)}function Mt(t){return arguments.length?this.property("__data__",t):this.node().__data__}function Lt(t,n,e){var r=$(t),i=r.CustomEvent;i?i=new i(n,e):(i=r.document.createEvent("Event"),e?(i.initEvent(n,e.bubbles,e.cancelable),i.detail=e.detail):i.initEvent(n,!1,!1)),t.dispatchEvent(i)}function Pt(t,n){return function(){return Lt(this,t,n)}}function Tt(t,n){return function(){return Lt(this,t,n.apply(this,arguments))}}function qt(t,n){return this.each(("function"==typeof n?Tt:Pt)(t,n))}function Ot(t,n){this._groups=t,this._parents=n}function Bt(){return new Ot([[document.documentElement]],Jt)}function Dt(t){return"string"==typeof t?new Ot([[document.querySelector(t)]],[document.documentElement]):new Ot([[t]],Jt)}function Vt(t){return"string"==typeof t?new Ot([document.querySelectorAll(t)],[document.documentElement]):new Ot([t],Jt)}function Rt(t,n,e){arguments.length<3&&(e=n,n=_().changedTouches);for(var r,i=0,o=n?n.length:0;o>i;++i)if((r=n[i]).identifier===e)return v(t,r);return null}function jt(t,n){null==n&&(n=_().touches);for(var e=0,r=n?n.length:0,i=new Array(r);r>e;++e)i[e]=v(t,n[e]);return i}var zt="http://www.w3.org/1999/xhtml",Ht={svg:"http://www.w3.org/2000/svg",xhtml:zt,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"},It=0;u.prototype=o.prototype={constructor:u,get:function(t){for(var n=this._;!(n in t);)if(!(t=t.parentNode))return;return t[n]},set:function(t,n){return t[this._]=n},remove:function(t){return this._ in t&&delete t[this._]},toString:function(){return this._}};var Ut=function(t){return function(){return this.matches(t)}};if("undefined"!=typeof document){var kt=document.documentElement;if(!kt.matches){var Gt=kt.webkitMatchesSelector||kt.msMatchesSelector||kt.mozMatchesSelector||kt.oMatchesSelector;Ut=function(t){return function(){return Gt.call(this,t)}}}}var Xt=Ut,Yt={};if(t.event=null,"undefined"!=typeof document){var $t=document.documentElement;"onmouseenter"in $t||(Yt={mouseenter:"mouseover",mouseleave:"mouseout"})}var Ft="$";N.prototype={constructor:N,appendChild:function(t){return this._parent.insertBefore(t,this._next)},insertBefore:function(t,n){return this._parent.insertBefore(t,n)},querySelector:function(t){return this._parent.querySelector(t)},querySelectorAll:function(t){return this._parent.querySelectorAll(t)}},it.prototype={add:function(t){var n=this._names.indexOf(t);0>n&&(this._names.push(t),this._node.setAttribute("class",this._names.join(" ")))},remove:function(t){var n=this._names.indexOf(t);n>=0&&(this._names.splice(n,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}};var Jt=[null];Ot.prototype=Bt.prototype={constructor:Ot,select:y,selectAll:w,filter:A,data:E,enter:M,exit:L,merge:P,order:T,sort:q,call:B,nodes:D,node:V,size:R,empty:j,each:z,attr:Y,style:Q,property:nt,classed:lt,text:_t,html:yt,raise:wt,lower:xt,append:St,insert:Et,remove:Ct,datum:Mt,on:h,dispatch:qt},t.creator=i,t.local=o,t.matcher=Xt,t.mouse=d,t.namespace=n,t.namespaces=Ht,t.select=Dt,t.selectAll=Vt,t.selection=Bt,t.selector=m,t.selectorAll=g,t.touch=Rt,t.touches=jt,t.window=$,t.customEvent=p,Object.defineProperty(t,"__esModule",{value:!0})});

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

export {version} from "./build/package";
export {default as creator} from "./src/creator";
export {default as local} from "./src/local";
export {default as matcher} from "./src/matcher";

@@ -4,0 +4,0 @@ export {default as mouse} from "./src/mouse";

{
"name": "d3-selection",
"version": "0.7.3",
"version": "0.8.0",
"description": "Data-driven DOM manipulation: select elements and join them to data.",

@@ -11,3 +11,3 @@ "keywords": [

],
"homepage": "https://github.com/d3/d3-selection",
"homepage": "https://d3js.org/d3-selection/",
"license": "BSD-3-Clause",

@@ -25,6 +25,6 @@ "author": {

"scripts": {
"pretest": "rm -rf build && mkdir build && json2module package.json > build/package.js && rollup -f umd -n d3_selection -o build/d3-selection.js -- index.js",
"pretest": "rm -rf build && mkdir build && rollup --banner \"$(preamble)\" -f umd -n d3 -o build/d3-selection.js -- index.js",
"test": "tape 'test/**/*-test.js' && eslint index.js src",
"prepublish": "npm run test && uglifyjs build/d3-selection.js -c -m -o build/d3-selection.min.js",
"postpublish": "VERSION=`node -e 'console.log(require(\"./package.json\").version)'`; git push && git push --tags && cp build/d3-selection.js ../d3.github.com/d3-selection.v0.7.js && cp build/d3-selection.min.js ../d3.github.com/d3-selection.v0.7.min.js && cd ../d3.github.com && git add d3-selection.v0.7.js d3-selection.v0.7.min.js && git commit -m \"d3-selection ${VERSION}\" && git push && cd - && zip -j build/d3-selection.zip -- LICENSE README.md build/d3-selection.js build/d3-selection.min.js"
"prepublish": "npm run test && uglifyjs --preamble \"$(preamble)\" build/d3-selection.js -c -m -o build/d3-selection.min.js",
"postpublish": "VERSION=`node -e 'console.log(require(\"./package.json\").version)'`; git push && git push --tags && cp build/d3-selection.js ../d3.github.com/d3-selection.v0.8.js && cp build/d3-selection.min.js ../d3.github.com/d3-selection.v0.8.min.js && cd ../d3.github.com && git add d3-selection.v0.8.js d3-selection.v0.8.min.js && git commit -m \"d3-selection ${VERSION}\" && git push && cd - && zip -j build/d3-selection.zip -- LICENSE README.md build/d3-selection.js build/d3-selection.min.js"
},

@@ -34,4 +34,4 @@ "devDependencies": {

"jsdom": "9",
"json2module": "0.0",
"rollup": "0.26",
"package-preamble": "0.0",
"rollup": "0.27",
"tape": "4",

@@ -38,0 +38,0 @@ "uglify-js": "2"

@@ -39,9 +39,9 @@ # d3-selection

If you use NPM, `npm install d3-selection`. Otherwise, download the [latest release](https://github.com/d3/d3-selection/releases/latest). You can also load directly from [d3js.org](https://d3js.org), either as a [standalone library](https://d3js.org/d3-selection.v0.7.min.js) or as part of [D3 4.0](https://github.com/d3/d3). AMD, CommonJS, and vanilla environments are supported. In vanilla, a `d3_selection` global is exported:
If you use NPM, `npm install d3-selection`. Otherwise, download the [latest release](https://github.com/d3/d3-selection/releases/latest). You can also load directly from [d3js.org](https://d3js.org), either as a [standalone library](https://d3js.org/d3-selection.v0.8.min.js) or as part of [D3 4.0](https://github.com/d3/d3). AMD, CommonJS, and vanilla environments are supported. In vanilla, a `d3` global is exported:
```html
<script src="https://d3js.org/d3-selection.v0.7.min.js"></script>
<script src="https://d3js.org/d3-selection.v0.8.min.js"></script>
<script>
var div = d3_selection.selectAll("div");
var div = d3.selectAll("div");

@@ -60,2 +60,3 @@ </script>

* [Control Flow](#control-flow)
* [Local Variables](#local-variables)
* [Namespaces](#namespaces)

@@ -316,7 +317,7 @@

Use [*selection*.append](#selection_append) instead to create data-driven content; this method is intended for when you want a little bit of HTML, say for rich formatting. Also, *selection*.html is only supported on HTML elements. SVG elements and other non-HTML elements do not support the innerHTML property, and thus are incompatible with *selection*.html. Consider using [XMLSerializer](https://developer.mozilla.org/en-US/docs/XMLSerializer) to convert a DOM subtree to text. See also the [innersvg polyfill](https://code.google.com/p/innersvg/), which provides a shim to support the innerHTML property on SVG elements.
Use [*selection*.append](#selection_append) or [*selection*.insert](#selection_insert) instead to create data-driven content; this method is intended for when you want a little bit of HTML, say for rich formatting. Also, *selection*.html is only supported on HTML elements. SVG elements and other non-HTML elements do not support the innerHTML property, and thus are incompatible with *selection*.html. Consider using [XMLSerializer](https://developer.mozilla.org/en-US/docs/XMLSerializer) to convert a DOM subtree to text. See also the [innersvg polyfill](https://code.google.com/p/innersvg/), which provides a shim to support the innerHTML property on SVG elements.
<a name="selection_append" href="#selection_append">#</a> <i>selection</i>.<b>append</b>(<i>type</i>[, <i>before</i>])
<a name="selection_append" href="#selection_append">#</a> <i>selection</i>.<b>append</b>(<i>type</i>)
If the specified *type* is a string, appends a new element of this type (tag name) as the last child of each element in this selection. Otherwise, the *type* may be a function which is evaluated for each selected element, in order, being passed the current datum *d* and index *i*, with the `this` context as the current DOM element. This function should return an element to be appended. Typically, the function creates a new element, but it may instead return an existing element. For example, to append a DIV element to each paragraph:
If the specified *type* is a string, appends a new element of this type (tag name) as the last child of each selected element, or the next following sibling in the update selection if this is an [enter selection](#selection_enter). (The enter behavior allows you to insert elements into the DOM in an order consistent with bound data; however, the slower [*selection*.order](#selection_order) may still be required if updating elements change order.) Otherwise, the *type* may be a function which is evaluated for each selected element, in order, being passed the current datum *d* and index *i*, with the `this` context as the current DOM element. This function should return an element to be appended. (The function typically creates a new element, but it may instead return an existing element.) For example, to append a DIV element to each paragraph:

@@ -335,6 +336,40 @@ ```js

Which is equivalent to:
```js
d3.selectAll("p").select(function() {
return this.appendChild(document.createElement("div"));
});
```
In both cases, this method returns a new selection containing the appended elements. Each new element inherits the data of the current elements, if any, in the same manner as [*selection*.select](#selection_select).
An optional *before* selector string or function may be specified. For instance, the selector `:first-child` will prepend nodes *before* the first child, rather than *after* the last child. If no *before* selector is specified on an [enter selection](#selection_enter), entering elements are inserted immediately before the next following sibling in the update selection, if any. This allows you to insert elements into the DOM in an order consistent with bound data. Note, however, the slower [*selection*.order](#selection_order) may still be required if updating elements change order. To append entering elements after the last child, explicitly specify a null *before* selector.
The specified *name* may have a namespace prefix, such as `svg:text` to specify a `text` attribute in the SVG namespace. See [namespaces](#namespaces) for the map of supported namespaces; additional namespaces can be registered by adding to the map. If no namespace is specified, the namespace will be inherited from the parent element; or, if the name is one of the known prefixes, the corresponding namespace will be used (for example, `svg` implies `svg:svg`).
<a name="selection_insert" href="#selection_insert">#</a> <i>selection</i>.<b>insert</b>(<i>type</i>, <i>before</i>)
If the specified *type* is a string, inserts a new element of this type (tag name) before the element matching the specified *before* selector for each selected element. For example, a *before* selector `:first-child` will prepend nodes before the first child. Both *type* and *before* may instead be specified as functions which are evaluated for each selected element, in order, being passed the current datum *d* and index *i*, with the `this` context as the current DOM element. The *type* function should return an element to be inserted; the *before* function should return the child element before which the element should be inserted. For example, to insert a DIV element to each paragraph:
```js
d3.selectAll("p").insert("div");
```
This is equivalent to:
```js
d3.selectAll("p").insert(function() {
return document.createElement("div");
});
```
Which is equivalent to:
```js
d3.selectAll("p").select(function() {
return this.insertBefore(document.createElement("div"), null);
});
```
In both cases, this method returns a new selection containing the appended elements. Each new element inherits the data of the current elements, if any, in the same manner as [*selection*.select](#selection_select).
The specified *name* may have a namespace prefix, such as `svg:text` to specify a `text` attribute in the SVG namespace. See [namespaces](#namespaces) for the map of supported namespaces; additional namespaces can be registered by adding to the map. If no namespace is specified, the namespace will be inherited from the parent element; or, if the name is one of the known prefixes, the corresponding namespace will be used (for example, `svg` implies `svg:svg`).

@@ -344,3 +379,3 @@

Removes the selected elements from the document. Returns this selection (the removed elements) which are now detached from the DOM. There is not currently a dedicated API to add removed elements back to the document; however, you can pass a function to [*selection*.append](#selection_append) to re-add elements.
Removes the selected elements from the document. Returns this selection (the removed elements) which are now detached from the DOM. There is not currently a dedicated API to add removed elements back to the document; however, you can pass a function to [*selection*.append](#selection_append) or [*selection*.insert](#selection_insert) to re-add elements.

@@ -381,3 +416,3 @@ <a name="selection_sort" href="#selection_sort">#</a> <i>selection</i>.<b>sort</b>(<i>compare</i>)

Given the specified element *name*, returns a function which creates an element of the given name, assuming that `this` is the parent element. This method is used internally by [*selection*.append](#selection_append) to create new elements. For example, this:
Given the specified element *name*, returns a function which creates an element of the given name, assuming that `this` is the parent element. This method is used internally by [*selection*.append](#selection_append) and [*selection*.insert](#selection_insert) to create new elements. For example, this:

@@ -653,2 +688,42 @@ ```js

### Local Variables
D3 locals allow you to define local state independent of data. For instance, when rendering [small multiples](http://bl.ocks.org/mbostock/e1192fe405703d8321a5187350910e08) of time-series data, you might want the same *x*-scale for all charts but distinct *y*-scales to compare the relative performance of each metric. D3 locals are scoped by DOM elements: on set, the value is stored on the given element; on get, the value is retrieved from given element or the nearest ancestor that defines it.
<a name="local" href="#local">#</a> d3.<b>local</b>()
Declares a new local variable. For example:
```js
var foo = d3.local();
```
Like `var`, each local is a distinct symbolic reference; unlike `var`, the value of each local is also scoped by the DOM.
<a name="local_set" href="#local_set">#</a> <i>local</i>.<b>set</b>(<i>node</i>, <i>value</i>)
Sets the value of this local on the specified *node* to the *value*, and returns the specified *value*. This is often performed using [*selection*.each](#selection_each):
```js
selection.each(function(d) { foo.set(this, d.value); });
```
If you are just setting a single variable, consider using [*selection*.property](#selection_property):
```js
selection.property(foo, function(d) { return d.value; });
```
<a name="local_get" href="#local_get">#</a> <i>local</i>.<b>get</b>(<i>node</i>)
Returns the value of this local on the specified *node*. If the *node* does not define this local, returns the value from the nearest ancestor that defines it. Returns undefined if no ancestor defines this local.
<a name="local_remove" href="#local_remove">#</a> <i>local</i>.<b>remove</b>(<i>node</i>)
Deletes this local’s value from the specified *node* and returns its previous value. Returns true if the *node* defined this local prior to removal, and false otherwise. If ancestors also define this local, those definitions are unaffected, and thus [*local*.get](#local_get) will still return the inherited value.
<a name="local_toString" href="#local_toString">#</a> <i>local</i>.<b>toString</b>()
Returns the automatically-generated identifier for this local. This is the name of the property that is used to store the local’s value on elements, and thus you can also set or get the local’s value using *element*[*local*] or by using [*selection*.property](#selection_property).
### Namespaces

@@ -655,0 +730,0 @@

import creator from "../creator";
import selector from "../selector";
function append(create) {
return function() {
export default function(name) {
var create = typeof name === "function" ? name : creator(name);
return this.select(function() {
return this.appendChild(create.apply(this, arguments));
};
});
}
function insert(create, select) {
return function() {
return this.insertBefore(create.apply(this, arguments), select.apply(this, arguments) || null);
};
}
function constantNull() {
return null;
}
export default function(name, before) {
var create = typeof name === "function" ? name : creator(name);
return this.select(arguments.length < 2
? append(create)
: insert(create, before == null
? constantNull : typeof before === "function"
? before
: selector(before)));
}

@@ -25,2 +25,3 @@ import selection_select from "./select";

import selection_append from "./append";
import selection_insert from "./insert";
import selection_remove from "./remove";

@@ -68,2 +69,3 @@ import selection_datum from "./datum";

append: selection_append,
insert: selection_insert,
remove: selection_remove,

@@ -70,0 +72,0 @@ datum: selection_datum,

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