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.5.0 to 1.6.0

CHANGELOG.md

22

d.js

@@ -28,11 +28,17 @@ 'use strict';

*/
d.get = function (query, context) {
d.get = function (query) {
if (typeof query === 'string') {
return (context || document).querySelector(query);
return document.querySelector(query);
}
if (query instanceof NodeList || query instanceof HTMLCollection || query instanceof Array) {
if (query instanceof NodeList || query instanceof HTMLCollection || query instanceof Array || query instanceof d) {
return query[0];
}
if (Object.prototype.toString.call(query) === '[object Object]') {
for (var q in query) {
return query[q].querySelector(q);
}
}
return query;

@@ -44,3 +50,3 @@ };

*/
d.getAll = function (query, context) {
d.getAll = function (query) {
if (Array.isArray(query)) {

@@ -51,3 +57,8 @@ return query;

if (typeof query === 'string') {
query = (context || document).querySelectorAll(query);
query = document.querySelectorAll(query);
} else if (Object.prototype.toString.call(query) === '[object Object]' && !(query instanceof d)) {
for (var q in query) {
query = query[q].querySelectorAll(q);
break;
}
}

@@ -59,2 +70,3 @@

return [query];

@@ -61,0 +73,0 @@ };

@@ -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 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,t 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(e,t){return"string"==typeof e?(t||document).querySelector(e):e instanceof NodeList||e instanceof HTMLCollection||e instanceof Array?e[0]:e},e.getAll=function(t,n){return Array.isArray(t)?t:("string"==typeof t&&(t=(n||document).querySelectorAll(t)),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,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});
"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});
{
"name": "d_js",
"version": "1.5.0",
"version": "1.6.0",
"description": "DOM manipulation micro-library",

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

"scripts": {
"build": "gulp",
"lint": "eslint d.js"
"build": "gulp",
"lint": "eslint d.js"
}
}

@@ -34,20 +34,20 @@ # d.js

### d.get(query, context)
### d.get(query)
Returns the first element found:
* **query** A string with the selector, array of elements or a Node/NodeList/HTMLCollection instance
* **context** An optional context (by default is `document`)
* **query** A string with the selector, array of elements, an object or a Node/NodeList/HTMLCollection instance
```js
var container = d.get('.container');
var buttonInContainer = d.get('.button', container);
//Use an object to specify the context
var buttonInContainer = d.get({'.button': container});
```
### d.getAll(query, context)
### d.getAll(query)
Returns an array with all elements found:
* **query** A string with the selector, array of elements or a Node/NodeList/HTMLCollection instance
* **context** An optional context (by default is `document`)
* **query** A string with the selector, array of elements, an object or a Node/NodeList/HTMLCollection instance

@@ -54,0 +54,0 @@ ```js

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