Socket
Socket
Sign inDemoInstall

d_js

Package Overview
Dependencies
0
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.6.0 to 1.7.0

6

CHANGELOG.md

@@ -7,2 +7,8 @@ # Change Log

## 1.7.0 - 2017-04-12
### Added
* New function `d.siblings()`
## 1.6.0 - 2017-02-24

@@ -9,0 +15,0 @@

@@ -71,2 +71,17 @@ 'use strict';

/**
* Select the siblings of an element
*/
d.getSiblings = function (element, query) {
element = d.get(element);
if (!element) {
return [];
}
return d.getAll(element.parentNode.children).filter(function (child) {
return child !== element && (!query || d.is(child, query));
});
};
/*

@@ -73,0 +88,0 @@ * Check whether the element matches with a selector

2

dist/d.js

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

"use strict";!function(e,t){"function"==typeof define&&define.amd?define([],function(){return t()}):"object"==typeof module&&module.exports?module.exports=t():e.d=t()}(this,function(){function e(n){return this instanceof e?void Array.prototype.splice.apply(this,[0,0].concat(n)):new e(t(n))}function t(t){return"string"==typeof t&&"<"===t[0]?e.parse(t,!0)||[]:e.getAll(t)}function n(e){if(e=e.replace(/(-\w)/g,function(e){return e[1].toUpperCase()}),e in o.style)return e;for(var t,n=e.charAt(0).toUpperCase()+e.slice(1),r=["Moz","Webkit","O","ms"],i=0;i<r.length;i++)if(t=r[i]+n,t in o.style)return t}function r(e,t){var n;return"on"+e in o?(n=document.createEvent("HTMLEvents"),n.initEvent(e,!0,!1),n):window.CustomEvent?new CustomEvent(e,{detail:t||{}}):(n=document.createEvent("CustomEvent"),n.initCustomEvent(e,!0,!0,t||{}),n)}var o=document.createElement("div");return e.get=function(t){if("string"==typeof t)return document.querySelector(t);if(t instanceof NodeList||t instanceof HTMLCollection||t instanceof Array||t instanceof e)return t[0];if("[object Object]"===Object.prototype.toString.call(t))for(var n in t)return t[n].querySelector(n);return t},e.getAll=function(t){if(Array.isArray(t))return t;if("string"==typeof t)t=document.querySelectorAll(t);else if("[object Object]"===Object.prototype.toString.call(t)&&!(t instanceof e))for(var n in t){t=t[n].querySelectorAll(n);break}return t instanceof NodeList||t instanceof HTMLCollection||t instanceof e?Array.prototype.slice.call(t):[t]},e.is=function(e,t){return"string"==typeof t?(e.matches||e.matchesSelector||e.msMatchesSelector||e.mozMatchesSelector||e.webkitMatchesSelector||e.oMatchesSelector).call(e,t):e===t},e.on=function(t,n,r,o){e.getAll(n).forEach(function(e){t.split(" ").forEach(function(t){e.addEventListener(t,r,o||!1)})})},e.delegate=function(t,n,r,o,i){e.on(t,n,function(t){for(var n=t.target;n&&n!==this;n=n.parentNode)if(e.is(n,r)){o.call(n,t);break}},i)},e.off=function(t,n,r,o){e.getAll(n).forEach(function(e){t.split(" ").forEach(function(t){e.removeEventListener(t,r,o||!1)})})},e.trigger=function(t,n,o){"string"==typeof t&&(t=r(t,o)),e.getAll(n).forEach(function(e){e.dispatchEvent(t)})},e.remove=function(t){e.getAll(t).forEach(function(e){e.parentNode.removeChild(e)})},e.insertBefore=function(n,r){var o=e.get(n);o&&t(r).forEach(function(e){o.parentNode.insertBefore(e,o)})},e.insertAfter=function(n,r){var o=e.get(n);o&&t(r).reverse().forEach(function(e){o.parentNode.insertBefore(e,o.nextSibling)})},e.prepend=function(n,r){var o=e.get(n);o&&t(r).reverse().forEach(function(e){o.insertBefore(e,o.firstChild)})},e.append=function(n,r){var o=e.get(n);o&&t(r).forEach(function(e){o.appendChild(e)})},e.css=function(t,r,o){if(arguments.length<3&&"object"!=typeof r){var i=getComputedStyle(e.get(t));return 1===arguments.length?i:i[n(r)]}var c={};"object"==typeof r?c=r:c[r]=o,e.getAll(t).forEach(function(e,t,r){for(var o in c){var i=c[o];"function"==typeof i?i=i.call(this,e,t,r):Array.isArray(i)&&(i=i[t%i.length]),e.style[n(o)]=i}})},e.parse=function(t,n){return o.innerHTML=t,0===o.children.length?n?[]:null:1!==o.children.length||n?e.getAll(o.children):o.children[0]},e.prototype=Object.create(Array.prototype,{on:{value:function(t,n,r){return e.on(t,this,n,r),this}},delegate:{value:function(t,n,r,o){return e.delegate(t,this,n,r,o),this}},off:{value:function(t,n,r){return e.off(t,this,n,r),this}},trigger:{value:function(t,n){return e.trigger(t,this,n),this}},css:{value:function(t){var n=Array.prototype.slice.call(arguments);return n.unshift(this),n.length<3&&"object"!=typeof t?e.css.apply(null,n):(e.css.apply(null,n),this)}},insertBefore:{value:function(t){return e.insertBefore(this,t),this}},insertAfter:{value:function(t){return e.insertAfter(this,t),this}},prepend:{value:function(t){return e.prepend(this,t),this}},append:{value:function(t){return e.append(this,t),this}},insertBeforeTo:{value:function(t){return e.insertBefore(t,this),this}},insertAfterTo:{value:function(t){return e.insertAfter(t,this),this}},prependTo:{value:function(t){return e.prepend(t,this),this}},appendTo:{value:function(t){return e.append(t,this),this}}}),e});
"use strict";!function(e,t){"function"==typeof define&&define.amd?define([],function(){return t()}):"object"==typeof module&&module.exports?module.exports=t():e.d=t()}(this,function(){function e(n){if(!(this instanceof e))return new e(t(n));Array.prototype.splice.apply(this,[0,0].concat(n))}function t(t){return"string"==typeof t&&"<"===t[0]?e.parse(t,!0)||[]:e.getAll(t)}function n(e){if((e=e.replace(/(-\w)/g,function(e){return e[1].toUpperCase()}))in i.style)return e;for(var t,n=e.charAt(0).toUpperCase()+e.slice(1),r=["Moz","Webkit","O","ms"],o=0;o<r.length;o++)if((t=r[o]+n)in i.style)return t}function r(e,t){var n;return"on"+e in i?(n=document.createEvent("HTMLEvents"),n.initEvent(e,!0,!1),n):window.CustomEvent?new CustomEvent(e,{detail:t||{}}):(n=document.createEvent("CustomEvent"),n.initCustomEvent(e,!0,!0,t||{}),n)}var i=document.createElement("div");return e.get=function(t){if("string"==typeof t)return document.querySelector(t);if(t instanceof NodeList||t instanceof HTMLCollection||t instanceof Array||t instanceof e)return t[0];if("[object Object]"===Object.prototype.toString.call(t))for(var n in t)return t[n].querySelector(n);return t},e.getAll=function(t){if(Array.isArray(t))return t;if("string"==typeof t)t=document.querySelectorAll(t);else if("[object Object]"===Object.prototype.toString.call(t)&&!(t instanceof e))for(var n in t){t=t[n].querySelectorAll(n);break}return t instanceof NodeList||t instanceof HTMLCollection||t instanceof e?Array.prototype.slice.call(t):[t]},e.getSiblings=function(t,n){return t=e.get(t),t?e.getAll(t.parentNode.children).filter(function(r){return r!==t&&(!n||e.is(r,n))}):[]},e.is=function(e,t){return"string"==typeof t?(e.matches||e.matchesSelector||e.msMatchesSelector||e.mozMatchesSelector||e.webkitMatchesSelector||e.oMatchesSelector).call(e,t):e===t},e.on=function(t,n,r,i){e.getAll(n).forEach(function(e){t.split(" ").forEach(function(t){e.addEventListener(t,r,i||!1)})})},e.delegate=function(t,n,r,i,o){e.on(t,n,function(t){for(var n=t.target;n&&n!==this;n=n.parentNode)if(e.is(n,r)){i.call(n,t);break}},o)},e.off=function(t,n,r,i){e.getAll(n).forEach(function(e){t.split(" ").forEach(function(t){e.removeEventListener(t,r,i||!1)})})},e.trigger=function(t,n,i){"string"==typeof t&&(t=r(t,i)),e.getAll(n).forEach(function(e){e.dispatchEvent(t)})},e.remove=function(t){e.getAll(t).forEach(function(e){e.parentNode.removeChild(e)})},e.insertBefore=function(n,r){var i=e.get(n);i&&t(r).forEach(function(e){i.parentNode.insertBefore(e,i)})},e.insertAfter=function(n,r){var i=e.get(n);i&&t(r).reverse().forEach(function(e){i.parentNode.insertBefore(e,i.nextSibling)})},e.prepend=function(n,r){var i=e.get(n);i&&t(r).reverse().forEach(function(e){i.insertBefore(e,i.firstChild)})},e.append=function(n,r){var i=e.get(n);i&&t(r).forEach(function(e){i.appendChild(e)})},e.css=function(t,r,i){if(arguments.length<3&&"object"!=typeof r){var o=getComputedStyle(e.get(t));return 1===arguments.length?o:o[n(r)]}var c={};"object"==typeof r?c=r:c[r]=i,e.getAll(t).forEach(function(e,t,r){for(var i in c){var o=c[i];"function"==typeof o?o=o.call(this,e,t,r):Array.isArray(o)&&(o=o[t%o.length]),e.style[n(i)]=o}})},e.parse=function(t,n){return i.innerHTML=t,0===i.children.length?n?[]:null:1!==i.children.length||n?e.getAll(i.children):i.children[0]},e.prototype=Object.create(Array.prototype,{on:{value:function(t,n,r){return e.on(t,this,n,r),this}},delegate:{value:function(t,n,r,i){return e.delegate(t,this,n,r,i),this}},off:{value:function(t,n,r){return e.off(t,this,n,r),this}},trigger:{value:function(t,n){return e.trigger(t,this,n),this}},css:{value:function(t){var n=Array.prototype.slice.call(arguments);return n.unshift(this),n.length<3&&"object"!=typeof t?e.css.apply(null,n):(e.css.apply(null,n),this)}},insertBefore:{value:function(t){return e.insertBefore(this,t),this}},insertAfter:{value:function(t){return e.insertAfter(this,t),this}},prepend:{value:function(t){return e.prepend(this,t),this}},append:{value:function(t){return e.append(this,t),this}},insertBeforeTo:{value:function(t){return e.insertBefore(t,this),this}},insertAfterTo:{value:function(t){return e.insertAfter(t,this),this}},prependTo:{value:function(t){return e.prepend(t,this),this}},appendTo:{value:function(t){return e.append(t,this),this}}}),e});
{
"name": "d_js",
"version": "1.6.0",
"version": "1.7.0",
"description": "DOM manipulation micro-library",

@@ -5,0 +5,0 @@ "main": "d.js",

@@ -59,2 +59,14 @@ # d.js

### d.getSiblings(element, query)
Returns an array with all siblings of another.
* **element** A string with the selector, array of elements, an object or a Node/NodeList/HTMLCollection instance
* **query** Optional string to filter the siblings
```js
d.getSiblings('li'); //return all siblings
d.getSiblings('li', '.filtered'); //return all siblings with class '.filtered'
```
### d.is(element, query)

@@ -61,0 +73,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc