Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

dom-set

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dom-set - npm Package Compare versions

Comparing version 1.0.1 to 1.1.0

src/lib/select.js

102

dist/bundle.es.js

@@ -5,7 +5,31 @@ import isElement from 'iselement';

function indexOfElement(elements, element) {
function select(selector){
if(typeof selector === 'string'){
try{
return document.querySelector(selector);
}catch(e){
throw e;
}
}else if(isElement(selector)){
return selector;
}
}
function selectAll(selector){
if(typeof selector === 'string'){
return Array.prototype.slice.apply(
document.querySelectorAll(selector)
);
}else if(isArray(selector)){
return selector.map(select);
}else if('length' in selector){
return arrayFrom(selector).map(select);
}
}
function indexOfElement(elements, element){
element = resolveElement(element, true);
if (!isElement(element)) return -1;
for (var i = 0; i < elements.length; i++) {
if (elements[i] === element) {
if(!isElement(element)) { return -1; }
for(var i=0; i<elements.length; i++){
if(elements[i] === element){
return i;

@@ -17,17 +41,17 @@ }

function hasElement(elements, element) {
function hasElement(elements, element){
return -1 !== indexOfElement(elements, element);
}
function domListOf(arr) {
function domListOf(arr){
if (!arr) return [];
if(!arr) { return []; }
try {
if (typeof arr === 'string') {
try{
if(typeof arr === 'string'){
return arrayFrom(document.querySelectorAll(arr));
} else if (isArray(arr)) {
}else if(isArray(arr)){
return arr.map(resolveElement);
} else {
if (typeof arr.length === 'undefined') {
}else{
if(typeof arr.length === 'undefined'){
return [resolveElement(arr)];

@@ -37,14 +61,15 @@ }

return arrayFrom(arr, resolveElement);
}
} catch (e) {
}catch(e){
throw new Error(e);
}
}
function concatElementLists() {
for (var _len = arguments.length, lists = Array(_len), _key = 0; _key < _len; _key++) {
lists[_key] = arguments[_key];
}
function concatElementLists(){
var lists = [], len = arguments.length;
while ( len-- ) lists[ len ] = arguments[ len ];
return lists.reduce(function (last, list) {
return lists.reduce(function (last, list){
return list.length ? last : last.concat(domListOf(list));

@@ -54,6 +79,7 @@ }, []);

function pushElements(elements, toAdd) {
function pushElements(elements, toAdd){
for (var i = 0; i < toAdd.length; i++) {
if (!hasElement(elements, toAdd[i])) elements.push(toAdd[i]);
for(var i=0; i<toAdd.length; i++){
if(!hasElement(elements, toAdd[i]))
{ elements.push(toAdd[i]); }
}

@@ -64,6 +90,5 @@

function addElements(elements) {
for (var _len2 = arguments.length, toAdd = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
toAdd[_key2 - 1] = arguments[_key2];
}
function addElements(elements){
var toAdd = [], len = arguments.length - 1;
while ( len-- > 0 ) toAdd[ len ] = arguments[ len + 1 ];

@@ -74,12 +99,12 @@ toAdd = toAdd.map(resolveElement);

function removeElements(elements) {
for (var _len3 = arguments.length, toRemove = Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
toRemove[_key3 - 1] = arguments[_key3];
}
function removeElements(elements){
var toRemove = [], len = arguments.length - 1;
while ( len-- > 0 ) toRemove[ len ] = arguments[ len + 1 ];
return toRemove.map(resolveElement).reduce(function (last, e) {
return toRemove.map(resolveElement).reduce(function (last, e){
var index = indexOfElement(elements, e);
if (index !== -1) return last.concat(elements.splice(index, 1));
if(index !== -1)
{ return last.concat(elements.splice(index, 1)); }
return last;

@@ -89,13 +114,14 @@ }, []);

function resolveElement(element, noThrow) {
if (typeof element === 'string') {
try {
function resolveElement(element, noThrow){
if(typeof element === 'string'){
try{
return document.querySelector(element);
} catch (e) {
}catch(e){
throw e;
}
}
if (!isElement(element) && !noThrow) {
throw new TypeError(element + ' is not a DOM element.');
if(!isElement(element) && !noThrow){
throw new TypeError((element + " is not a DOM element."));
}

@@ -105,3 +131,3 @@ return element;

export { indexOfElement, hasElement, domListOf, concatElementLists, addElements, removeElements, resolveElement };
export { indexOfElement, hasElement, domListOf, concatElementLists, addElements, removeElements, resolveElement, select, selectAll };
//# sourceMappingURL=bundle.es.js.map

@@ -11,7 +11,31 @@ 'use strict';

function indexOfElement(elements, element) {
function select(selector){
if(typeof selector === 'string'){
try{
return document.querySelector(selector);
}catch(e){
throw e;
}
}else if(isElement(selector)){
return selector;
}
}
function selectAll(selector){
if(typeof selector === 'string'){
return Array.prototype.slice.apply(
document.querySelectorAll(selector)
);
}else if(isArray(selector)){
return selector.map(select);
}else if('length' in selector){
return arrayFrom(selector).map(select);
}
}
function indexOfElement(elements, element){
element = resolveElement(element, true);
if (!isElement(element)) return -1;
for (var i = 0; i < elements.length; i++) {
if (elements[i] === element) {
if(!isElement(element)) { return -1; }
for(var i=0; i<elements.length; i++){
if(elements[i] === element){
return i;

@@ -23,17 +47,17 @@ }

function hasElement(elements, element) {
function hasElement(elements, element){
return -1 !== indexOfElement(elements, element);
}
function domListOf(arr) {
function domListOf(arr){
if (!arr) return [];
if(!arr) { return []; }
try {
if (typeof arr === 'string') {
try{
if(typeof arr === 'string'){
return arrayFrom(document.querySelectorAll(arr));
} else if (isArray(arr)) {
}else if(isArray(arr)){
return arr.map(resolveElement);
} else {
if (typeof arr.length === 'undefined') {
}else{
if(typeof arr.length === 'undefined'){
return [resolveElement(arr)];

@@ -43,14 +67,15 @@ }

return arrayFrom(arr, resolveElement);
}
} catch (e) {
}catch(e){
throw new Error(e);
}
}
function concatElementLists() {
for (var _len = arguments.length, lists = Array(_len), _key = 0; _key < _len; _key++) {
lists[_key] = arguments[_key];
}
function concatElementLists(){
var lists = [], len = arguments.length;
while ( len-- ) lists[ len ] = arguments[ len ];
return lists.reduce(function (last, list) {
return lists.reduce(function (last, list){
return list.length ? last : last.concat(domListOf(list));

@@ -60,6 +85,7 @@ }, []);

function pushElements(elements, toAdd) {
function pushElements(elements, toAdd){
for (var i = 0; i < toAdd.length; i++) {
if (!hasElement(elements, toAdd[i])) elements.push(toAdd[i]);
for(var i=0; i<toAdd.length; i++){
if(!hasElement(elements, toAdd[i]))
{ elements.push(toAdd[i]); }
}

@@ -70,6 +96,5 @@

function addElements(elements) {
for (var _len2 = arguments.length, toAdd = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
toAdd[_key2 - 1] = arguments[_key2];
}
function addElements(elements){
var toAdd = [], len = arguments.length - 1;
while ( len-- > 0 ) toAdd[ len ] = arguments[ len + 1 ];

@@ -80,12 +105,12 @@ toAdd = toAdd.map(resolveElement);

function removeElements(elements) {
for (var _len3 = arguments.length, toRemove = Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
toRemove[_key3 - 1] = arguments[_key3];
}
function removeElements(elements){
var toRemove = [], len = arguments.length - 1;
while ( len-- > 0 ) toRemove[ len ] = arguments[ len + 1 ];
return toRemove.map(resolveElement).reduce(function (last, e) {
return toRemove.map(resolveElement).reduce(function (last, e){
var index = indexOfElement(elements, e);
if (index !== -1) return last.concat(elements.splice(index, 1));
if(index !== -1)
{ return last.concat(elements.splice(index, 1)); }
return last;

@@ -95,13 +120,14 @@ }, []);

function resolveElement(element, noThrow) {
if (typeof element === 'string') {
try {
function resolveElement(element, noThrow){
if(typeof element === 'string'){
try{
return document.querySelector(element);
} catch (e) {
}catch(e){
throw e;
}
}
if (!isElement(element) && !noThrow) {
throw new TypeError(element + ' is not a DOM element.');
if(!isElement(element) && !noThrow){
throw new TypeError((element + " is not a DOM element."));
}

@@ -118,2 +144,4 @@ return element;

exports.resolveElement = resolveElement;
exports.select = select;
exports.selectAll = selectAll;
//# sourceMappingURL=bundle.js.map
(function (exports) {
'use strict';
'use strict';
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
return typeof obj;
} : function (obj) {
return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj;
};
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; };
/**
* Returns `true` if provided input is Element.
* @name isElement
* @param {*} [input]
* @returns {boolean}
*/
function isElement (input) {
return input != null && (typeof input === 'undefined' ? 'undefined' : _typeof(input)) === 'object' && input.nodeType === 1 && _typeof(input.style) === 'object' && _typeof(input.ownerDocument) === 'object';
/**
* Returns `true` if provided input is Element.
* @name isElement
* @param {*} [input]
* @returns {boolean}
*/
var isElement = function (input) {
return input != null && (typeof input === 'undefined' ? 'undefined' : _typeof(input)) === 'object' && input.nodeType === 1 && _typeof(input.style) === 'object' && _typeof(input.ownerDocument) === 'object';
};
// Production steps of ECMA-262, Edition 6, 22.1.2.1
// Reference: http://www.ecma-international.org/ecma-262/6.0/#sec-array.from
var polyfill = (function() {
var isCallable = function(fn) {
return typeof fn === 'function';
};
var toInteger = function (value) {
var number = Number(value);
if (isNaN(number)) { return 0; }
if (number === 0 || !isFinite(number)) { return number; }
return (number > 0 ? 1 : -1) * Math.floor(Math.abs(number));
};
var maxSafeInteger = Math.pow(2, 53) - 1;
var toLength = function (value) {
var len = toInteger(value);
return Math.min(Math.max(len, 0), maxSafeInteger);
};
var iteratorProp = function(value) {
if(value != null) {
if(['string','number','boolean','symbol'].indexOf(typeof value) > -1){
return Symbol.iterator;
} else if (
(typeof Symbol !== 'undefined') &&
('iterator' in Symbol) &&
(Symbol.iterator in value)
) {
return Symbol.iterator;
}
// Support "@@iterator" placeholder, Gecko 27 to Gecko 35
else if ('@@iterator' in value) {
return '@@iterator';
}
}
};
var getMethod = function(O, P) {
// Assert: IsPropertyKey(P) is true.
if (O != null && P != null) {
// Let func be GetV(O, P).
var func = O[P];
// ReturnIfAbrupt(func).
// If func is either undefined or null, return undefined.
if(func == null) {
return void 0;
}
// If IsCallable(func) is false, throw a TypeError exception.
if (!isCallable(func)) {
throw new TypeError(func + ' is not a function');
}
return func;
}
};
var iteratorStep = function(iterator) {
// Let result be IteratorNext(iterator).
// ReturnIfAbrupt(result).
var result = iterator.next();
// Let done be IteratorComplete(result).
// ReturnIfAbrupt(done).
var done = Boolean(result.done);
// If done is true, return false.
if(done) {
return false;
}
// Return result.
return result;
};
// Production steps of ECMA-262, Edition 6, 22.1.2.1
// Reference: http://www.ecma-international.org/ecma-262/6.0/#sec-array.from
var __moduleExports = function () {
var isCallable = function (fn) {
return typeof fn === 'function';
};
var toInteger = function (value) {
var number = Number(value);
if (isNaN(number)) {
return 0;
}
if (number === 0 || !isFinite(number)) {
return number;
}
return (number > 0 ? 1 : -1) * Math.floor(Math.abs(number));
};
var maxSafeInteger = Math.pow(2, 53) - 1;
var toLength = function (value) {
var len = toInteger(value);
return Math.min(Math.max(len, 0), maxSafeInteger);
};
var iteratorProp = function (value) {
if (value != null) {
if (['string', 'number', 'boolean', 'symbol'].indexOf(typeof value) > -1) {
return Symbol.iterator;
} else if (typeof Symbol !== 'undefined' && 'iterator' in Symbol && Symbol.iterator in value) {
return Symbol.iterator;
}
// Support "@@iterator" placeholder, Gecko 27 to Gecko 35
else if ('@@iterator' in value) {
return '@@iterator';
}
}
};
var getMethod = function (O, P) {
// Assert: IsPropertyKey(P) is true.
if (O != null && P != null) {
// Let func be GetV(O, P).
var func = O[P];
// ReturnIfAbrupt(func).
// If func is either undefined or null, return undefined.
if (func == null) {
return void 0;
}
// If IsCallable(func) is false, throw a TypeError exception.
if (!isCallable(func)) {
throw new TypeError(func + ' is not a function');
}
return func;
}
};
var iteratorStep = function (iterator) {
// Let result be IteratorNext(iterator).
// ReturnIfAbrupt(result).
var result = iterator.next();
// Let done be IteratorComplete(result).
// ReturnIfAbrupt(done).
var done = Boolean(result.done);
// If done is true, return false.
if (done) {
return false;
}
// Return result.
return result;
};
// The length property of the from method is 1.
return function from(items /*, mapFn, thisArg */ ) {
'use strict';
// The length property of the from method is 1.
return function from(items /*, mapFn, thisArg */) {
'use strict';
// 1. Let C be the this value.
var C = this;
// 1. Let C be the this value.
// 2. If mapfn is undefined, let mapping be false.
var mapFn = arguments.length > 1 ? arguments[1] : void 0;
var C = this;
var T;
if (typeof mapFn !== 'undefined') {
// 3. else
// a. If IsCallable(mapfn) is false, throw a TypeError exception.
if (!isCallable(mapFn)) {
throw new TypeError(
'Array.from: when provided, the second argument must be a function'
);
}
// 2. If mapfn is undefined, let mapping be false.
var mapFn = arguments.length > 1 ? arguments[1] : void 0;
// b. If thisArg was supplied, let T be thisArg; else let T
// be undefined.
if (arguments.length > 2) {
T = arguments[2];
}
// c. Let mapping be true (implied by mapFn)
}
var T;
if (typeof mapFn !== 'undefined') {
// 3. else
// a. If IsCallable(mapfn) is false, throw a TypeError exception.
if (!isCallable(mapFn)) {
throw new TypeError('Array.from: when provided, the second argument must be a function');
}
var A, k;
// b. If thisArg was supplied, let T be thisArg; else let T
// be undefined.
if (arguments.length > 2) {
T = arguments[2];
}
// c. Let mapping be true (implied by mapFn)
}
// 4. Let usingIterator be GetMethod(items, @@iterator).
// 5. ReturnIfAbrupt(usingIterator).
var usingIterator = getMethod(items, iteratorProp(items));
var A, k;
// 6. If usingIterator is not undefined, then
if (usingIterator !== void 0) {
// a. If IsConstructor(C) is true, then
// i. Let A be the result of calling the [[Construct]]
// internal method of C with an empty argument list.
// b. Else,
// i. Let A be the result of the abstract operation ArrayCreate
// with argument 0.
// c. ReturnIfAbrupt(A).
A = isCallable(C) ? Object(new C()) : [];
// 4. Let usingIterator be GetMethod(items, @@iterator).
// 5. ReturnIfAbrupt(usingIterator).
var usingIterator = getMethod(items, iteratorProp(items));
// d. Let iterator be GetIterator(items, usingIterator).
var iterator = usingIterator.call(items);
// 6. If usingIterator is not undefined, then
if (usingIterator !== void 0) {
// a. If IsConstructor(C) is true, then
// i. Let A be the result of calling the [[Construct]]
// internal method of C with an empty argument list.
// b. Else,
// i. Let A be the result of the abstract operation ArrayCreate
// with argument 0.
// c. ReturnIfAbrupt(A).
A = isCallable(C) ? Object(new C()) : [];
// e. ReturnIfAbrupt(iterator).
if (iterator == null) {
throw new TypeError(
'Array.from requires an array-like or iterable object'
);
}
// d. Let iterator be GetIterator(items, usingIterator).
var iterator = usingIterator.call(items);
// f. Let k be 0.
k = 0;
// e. ReturnIfAbrupt(iterator).
if (iterator == null) {
throw new TypeError('Array.from requires an array-like or iterable object');
}
// g. Repeat
var next, nextValue;
while (true) {
// i. Let Pk be ToString(k).
// ii. Let next be IteratorStep(iterator).
// iii. ReturnIfAbrupt(next).
next = iteratorStep(iterator);
// f. Let k be 0.
k = 0;
// iv. If next is false, then
if (!next) {
// g. Repeat
var next, nextValue;
while (true) {
// i. Let Pk be ToString(k).
// ii. Let next be IteratorStep(iterator).
// iii. ReturnIfAbrupt(next).
next = iteratorStep(iterator);
// 1. Let setStatus be Set(A, "length", k, true).
// 2. ReturnIfAbrupt(setStatus).
A.length = k;
// iv. If next is false, then
if (!next) {
// 3. Return A.
return A;
}
// v. Let nextValue be IteratorValue(next).
// vi. ReturnIfAbrupt(nextValue)
nextValue = next.value;
// 1. Let setStatus be Set(A, "length", k, true).
// 2. ReturnIfAbrupt(setStatus).
A.length = k;
// vii. If mapping is true, then
// 1. Let mappedValue be Call(mapfn, T, «nextValue, k»).
// 2. If mappedValue is an abrupt completion, return
// IteratorClose(iterator, mappedValue).
// 3. Let mappedValue be mappedValue.[[value]].
// viii. Else, let mappedValue be nextValue.
// ix. Let defineStatus be the result of
// CreateDataPropertyOrThrow(A, Pk, mappedValue).
// x. [TODO] If defineStatus is an abrupt completion, return
// IteratorClose(iterator, defineStatus).
if (mapFn) {
A[k] = mapFn.call(T, nextValue, k);
}
else {
A[k] = nextValue;
}
// xi. Increase k by 1.
k++;
}
// 7. Assert: items is not an Iterable so assume it is
// an array-like object.
} else {
// 3. Return A.
return A;
}
// v. Let nextValue be IteratorValue(next).
// vi. ReturnIfAbrupt(nextValue)
nextValue = next.value;
// 8. Let arrayLike be ToObject(items).
var arrayLike = Object(items);
// vii. If mapping is true, then
// 1. Let mappedValue be Call(mapfn, T, «nextValue, k»).
// 2. If mappedValue is an abrupt completion, return
// IteratorClose(iterator, mappedValue).
// 3. Let mappedValue be mappedValue.[[value]].
// viii. Else, let mappedValue be nextValue.
// ix. Let defineStatus be the result of
// CreateDataPropertyOrThrow(A, Pk, mappedValue).
// x. [TODO] If defineStatus is an abrupt completion, return
// IteratorClose(iterator, defineStatus).
if (mapFn) {
A[k] = mapFn.call(T, nextValue, k);
} else {
A[k] = nextValue;
}
// xi. Increase k by 1.
k++;
}
// 7. Assert: items is not an Iterable so assume it is
// an array-like object.
} else {
// 9. ReturnIfAbrupt(items).
if (items == null) {
throw new TypeError(
'Array.from requires an array-like object - not null or undefined'
);
}
// 8. Let arrayLike be ToObject(items).
var arrayLike = Object(items);
// 10. Let len be ToLength(Get(arrayLike, "length")).
// 11. ReturnIfAbrupt(len).
var len = toLength(arrayLike.length);
// 9. ReturnIfAbrupt(items).
if (items == null) {
throw new TypeError('Array.from requires an array-like object - not null or undefined');
}
// 12. If IsConstructor(C) is true, then
// a. Let A be Construct(C, «len»).
// 13. Else
// a. Let A be ArrayCreate(len).
// 14. ReturnIfAbrupt(A).
A = isCallable(C) ? Object(new C(len)) : new Array(len);
// 10. Let len be ToLength(Get(arrayLike, "length")).
// 11. ReturnIfAbrupt(len).
var len = toLength(arrayLike.length);
// 12. If IsConstructor(C) is true, then
// a. Let A be Construct(C, «len»).
// 13. Else
// a. Let A be ArrayCreate(len).
// 14. ReturnIfAbrupt(A).
A = isCallable(C) ? Object(new C(len)) : new Array(len);
// 15. Let k be 0.
k = 0;
// 16. Repeat, while k < len… (also steps a - h)
var kValue;
while (k < len) {
kValue = arrayLike[k];
if (mapFn) {
A[k] = mapFn.call(T, kValue, k);
} else {
A[k] = kValue;
}
k++;
}
// 17. Let setStatus be Set(A, "length", len, true).
// 18. ReturnIfAbrupt(setStatus).
A.length = len;
// 19. Return A.
// 15. Let k be 0.
k = 0;
// 16. Repeat, while k < len… (also steps a - h)
var kValue;
while (k < len) {
kValue = arrayLike[k];
if (mapFn) {
A[k] = mapFn.call(T, kValue, k);
}
return A;
};
}();
else {
A[k] = kValue;
}
k++;
}
// 17. Let setStatus be Set(A, "length", len, true).
// 18. ReturnIfAbrupt(setStatus).
A.length = len;
// 19. Return A.
}
return A;
};
})();
var index = typeof Array.from === 'function' ? Array.from : __moduleExports;
var index = (typeof Array.from === 'function' ?
Array.from :
polyfill
);
/**
* isArray
*/
/**
* isArray
*/
var isArray = Array.isArray;
var isArray = Array.isArray;
/**
* toString
*/
/**
* toString
*/
var str = Object.prototype.toString;
var str = Object.prototype.toString;
/**
* Whether or not the given `val`
* is an array.
*
* example:
*
* isArray([]);
* // > true
* isArray(arguments);
* // > false
* isArray('');
* // > false
*
* @param {mixed} val
* @return {bool}
*/
/**
* Whether or not the given `val`
* is an array.
*
* example:
*
* isArray([]);
* // > true
* isArray(arguments);
* // > false
* isArray('');
* // > false
*
* @param {mixed} val
* @return {bool}
*/
var index$1 = isArray || function (val) {
return !!val && '[object Array]' == str.call(val);
};
var index$1 = isArray || function (val) {
return !! val && '[object Array]' == str.call(val);
};
function indexOfElement(elements, element) {
element = resolveElement(element, true);
if (!isElement(element)) return -1;
for (var i = 0; i < elements.length; i++) {
if (elements[i] === element) {
return i;
}
function select(selector){
if(typeof selector === 'string'){
try{
return document.querySelector(selector);
}catch(e){
throw e;
}
return -1;
}else if(isElement(selector)){
return selector;
}
}
function hasElement(elements, element) {
return -1 !== indexOfElement(elements, element);
function selectAll(selector){
if(typeof selector === 'string'){
return Array.prototype.slice.apply(
document.querySelectorAll(selector)
);
}else if(index$1(selector)){
return selector.map(select);
}else if('length' in selector){
return index(selector).map(select);
}
}
function domListOf(arr) {
function indexOfElement(elements, element){
element = resolveElement(element, true);
if(!isElement(element)) { return -1; }
for(var i=0; i<elements.length; i++){
if(elements[i] === element){
return i;
}
}
return -1;
}
if (!arr) return [];
function hasElement(elements, element){
return -1 !== indexOfElement(elements, element);
}
try {
if (typeof arr === 'string') {
return index(document.querySelectorAll(arr));
} else if (index$1(arr)) {
return arr.map(resolveElement);
} else {
if (typeof arr.length === 'undefined') {
return [resolveElement(arr)];
}
function domListOf(arr){
return index(arr, resolveElement);
if(!arr) { return []; }
try{
if(typeof arr === 'string'){
return index(document.querySelectorAll(arr));
}else if(index$1(arr)){
return arr.map(resolveElement);
}else{
if(typeof arr.length === 'undefined'){
return [resolveElement(arr)];
}
} catch (e) {
throw new Error(e);
return index(arr, resolveElement);
}
}catch(e){
throw new Error(e);
}
function concatElementLists() {
for (var _len = arguments.length, lists = Array(_len), _key = 0; _key < _len; _key++) {
lists[_key] = arguments[_key];
}
}
return lists.reduce(function (last, list) {
return list.length ? last : last.concat(domListOf(list));
}, []);
}
function concatElementLists(){
var lists = [], len = arguments.length;
while ( len-- ) lists[ len ] = arguments[ len ];
function pushElements(elements, toAdd) {
return lists.reduce(function (last, list){
return list.length ? last : last.concat(domListOf(list));
}, []);
}
for (var i = 0; i < toAdd.length; i++) {
if (!hasElement(elements, toAdd[i])) elements.push(toAdd[i]);
}
function pushElements(elements, toAdd){
return toAdd;
for(var i=0; i<toAdd.length; i++){
if(!hasElement(elements, toAdd[i]))
{ elements.push(toAdd[i]); }
}
function addElements(elements) {
for (var _len2 = arguments.length, toAdd = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
toAdd[_key2 - 1] = arguments[_key2];
}
return toAdd;
}
toAdd = toAdd.map(resolveElement);
return pushElements(elements, toAdd);
}
function addElements(elements){
var toAdd = [], len = arguments.length - 1;
while ( len-- > 0 ) toAdd[ len ] = arguments[ len + 1 ];
function removeElements(elements) {
for (var _len3 = arguments.length, toRemove = Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
toRemove[_key3 - 1] = arguments[_key3];
}
toAdd = toAdd.map(resolveElement);
return pushElements(elements, toAdd);
}
return toRemove.map(resolveElement).reduce(function (last, e) {
function removeElements(elements){
var toRemove = [], len = arguments.length - 1;
while ( len-- > 0 ) toRemove[ len ] = arguments[ len + 1 ];
var index = indexOfElement(elements, e);
return toRemove.map(resolveElement).reduce(function (last, e){
if (index !== -1) return last.concat(elements.splice(index, 1));
return last;
}, []);
}
var index$$1 = indexOfElement(elements, e);
function resolveElement(element, noThrow) {
if (typeof element === 'string') {
try {
return document.querySelector(element);
} catch (e) {
throw e;
}
if(index$$1 !== -1)
{ return last.concat(elements.splice(index$$1, 1)); }
return last;
}, []);
}
function resolveElement(element, noThrow){
if(typeof element === 'string'){
try{
return document.querySelector(element);
}catch(e){
throw e;
}
if (!isElement(element) && !noThrow) {
throw new TypeError(element + ' is not a DOM element.');
}
return element;
}
exports.indexOfElement = indexOfElement;
exports.hasElement = hasElement;
exports.domListOf = domListOf;
exports.concatElementLists = concatElementLists;
exports.addElements = addElements;
exports.removeElements = removeElements;
exports.resolveElement = resolveElement;
if(!isElement(element) && !noThrow){
throw new TypeError((element + " is not a DOM element."));
}
return element;
}
exports.indexOfElement = indexOfElement;
exports.hasElement = hasElement;
exports.domListOf = domListOf;
exports.concatElementLists = concatElementLists;
exports.addElements = addElements;
exports.removeElements = removeElements;
exports.resolveElement = resolveElement;
exports.select = select;
exports.selectAll = selectAll;
}((this.domSet = this.domSet || {})));
//# sourceMappingURL=dom-set.js.map

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

!function(r){"use strict";function n(r){return null!=r&&"object"===("undefined"==typeof r?"undefined":c(r))&&1===r.nodeType&&"object"===c(r.style)&&"object"===c(r.ownerDocument)}function t(r,t){if(t=l(t,!0),!n(t))return-1;for(var e=0;e<r.length;e++)if(r[e]===t)return e;return-1}function e(r,n){return-1!==t(r,n)}function o(r){if(!r)return[];try{return"string"==typeof r?m(document.querySelectorAll(r)):d(r)?r.map(l):"undefined"==typeof r.length?[l(r)]:m(r,l)}catch(r){throw new Error(r)}}function i(){for(var r=arguments.length,n=Array(r),t=0;t<r;t++)n[t]=arguments[t];return n.reduce(function(r,n){return n.length?r:r.concat(o(n))},[])}function u(r,n){for(var t=0;t<n.length;t++)e(r,n[t])||r.push(n[t]);return n}function f(r){for(var n=arguments.length,t=Array(n>1?n-1:0),e=1;e<n;e++)t[e-1]=arguments[e];return t=t.map(l),u(r,t)}function a(r){for(var n=arguments.length,e=Array(n>1?n-1:0),o=1;o<n;o++)e[o-1]=arguments[o];return e.map(l).reduce(function(n,e){var o=t(r,e);return o!==-1?n.concat(r.splice(o,1)):n},[])}function l(r,t){if("string"==typeof r)try{return document.querySelector(r)}catch(r){throw r}if(!n(r)&&!t)throw new TypeError(r+" is not a DOM element.");return r}var c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(r){return typeof r}:function(r){return r&&"function"==typeof Symbol&&r.constructor===Symbol?"symbol":typeof r},y=function(){var r=function(r){return"function"==typeof r},n=function(r){var n=Number(r);return isNaN(n)?0:0!==n&&isFinite(n)?(n>0?1:-1)*Math.floor(Math.abs(n)):n},t=Math.pow(2,53)-1,e=function(r){var e=n(r);return Math.min(Math.max(e,0),t)},o=function(r){if(null!=r){if(["string","number","boolean","symbol"].indexOf(typeof r)>-1)return Symbol.iterator;if("undefined"!=typeof Symbol&&"iterator"in Symbol&&Symbol.iterator in r)return Symbol.iterator;if("@@iterator"in r)return"@@iterator"}},i=function(n,t){if(null!=n&&null!=t){var e=n[t];if(null==e)return;if(!r(e))throw new TypeError(e+" is not a function");return e}},u=function(r){var n=r.next(),t=Boolean(n.done);return!t&&n};return function(n){var t,f=this,a=arguments.length>1?arguments[1]:void 0;if("undefined"!=typeof a){if(!r(a))throw new TypeError("Array.from: when provided, the second argument must be a function");arguments.length>2&&(t=arguments[2])}var l,c,y=i(n,o(n));if(void 0!==y){l=r(f)?Object(new f):[];var m=y.call(n);if(null==m)throw new TypeError("Array.from requires an array-like or iterable object");c=0;for(var h,s;;){if(h=u(m),!h)return l.length=c,l;s=h.value,a?l[c]=a.call(t,s,c):l[c]=s,c++}}else{var d=Object(n);if(null==n)throw new TypeError("Array.from requires an array-like object - not null or undefined");var p=e(d.length);l=r(f)?Object(new f(p)):new Array(p),c=0;for(var b;c<p;)b=d[c],a?l[c]=a.call(t,b,c):l[c]=b,c++;l.length=p}return l}}(),m="function"==typeof Array.from?Array.from:y,h=Array.isArray,s=Object.prototype.toString,d=h||function(r){return!!r&&"[object Array]"==s.call(r)};r.indexOfElement=t,r.hasElement=e,r.domListOf=o,r.concatElementLists=i,r.addElements=f,r.removeElements=a,r.resolveElement=l}(this.domSet=this.domSet||{});
!function(r){"use strict";function t(r){if("string"==typeof r)try{return document.querySelector(r)}catch(r){throw r}else if(m(r))return r}function e(r){return"string"==typeof r?Array.prototype.slice.apply(document.querySelectorAll(r)):b(r)?r.map(t):"length"in r?p(r).map(t):void 0}function n(r,t){if(t=c(t,!0),!m(t))return-1;for(var e=0;e<r.length;e++)if(r[e]===t)return e;return-1}function o(r,t){return-1!==n(r,t)}function i(r){if(!r)return[];try{return"string"==typeof r?p(document.querySelectorAll(r)):b(r)?r.map(c):"undefined"==typeof r.length?[c(r)]:p(r,c)}catch(r){throw new Error(r)}}function u(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];return r.reduce(function(r,t){return t.length?r:r.concat(i(t))},[])}function f(r,t){for(var e=0;e<t.length;e++)o(r,t[e])||r.push(t[e]);return t}function l(r){for(var t=[],e=arguments.length-1;e-- >0;)t[e]=arguments[e+1];return t=t.map(c),f(r,t)}function a(r){for(var t=[],e=arguments.length-1;e-- >0;)t[e]=arguments[e+1];return t.map(c).reduce(function(t,e){var o=n(r,e);return o!==-1?t.concat(r.splice(o,1)):t},[])}function c(r,t){if("string"==typeof r)try{return document.querySelector(r)}catch(r){throw r}if(!m(r)&&!t)throw new TypeError(r+" is not a DOM element.");return r}var y="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(r){return typeof r}:function(r){return r&&"function"==typeof Symbol&&r.constructor===Symbol?"symbol":typeof r},m=function(r){return null!=r&&"object"===("undefined"==typeof r?"undefined":y(r))&&1===r.nodeType&&"object"===y(r.style)&&"object"===y(r.ownerDocument)},s=function(){var r=function(r){return"function"==typeof r},t=function(r){var t=Number(r);return isNaN(t)?0:0!==t&&isFinite(t)?(t>0?1:-1)*Math.floor(Math.abs(t)):t},e=Math.pow(2,53)-1,n=function(r){var n=t(r);return Math.min(Math.max(n,0),e)},o=function(r){if(null!=r){if(["string","number","boolean","symbol"].indexOf(typeof r)>-1)return Symbol.iterator;if("undefined"!=typeof Symbol&&"iterator"in Symbol&&Symbol.iterator in r)return Symbol.iterator;if("@@iterator"in r)return"@@iterator"}},i=function(t,e){if(null!=t&&null!=e){var n=t[e];if(null==n)return;if(!r(n))throw new TypeError(n+" is not a function");return n}},u=function(r){var t=r.next(),e=Boolean(t.done);return!e&&t};return function(t){var e,f=this,l=arguments.length>1?arguments[1]:void 0;if("undefined"!=typeof l){if(!r(l))throw new TypeError("Array.from: when provided, the second argument must be a function");arguments.length>2&&(e=arguments[2])}var a,c,y=i(t,o(t));if(void 0!==y){a=r(f)?Object(new f):[];var m=y.call(t);if(null==m)throw new TypeError("Array.from requires an array-like or iterable object");c=0;for(var s,p;;){if(s=u(m),!s)return a.length=c,a;p=s.value,l?a[c]=l.call(e,p,c):a[c]=p,c++}}else{var h=Object(t);if(null==t)throw new TypeError("Array.from requires an array-like object - not null or undefined");var d=n(h.length);a=r(f)?Object(new f(d)):new Array(d),c=0;for(var b;c<d;)b=h[c],l?a[c]=l.call(e,b,c):a[c]=b,c++;a.length=d}return a}}(),p="function"==typeof Array.from?Array.from:s,h=Array.isArray,d=Object.prototype.toString,b=h||function(r){return!!r&&"[object Array]"==d.call(r)};r.indexOfElement=n,r.hasElement=o,r.domListOf=i,r.concatElementLists=u,r.addElements=l,r.removeElements=a,r.resolveElement=c,r.select=t,r.selectAll=e}(this.domSet=this.domSet||{});
{
"name": "dom-set",
"version": "1.0.1",
"version": "1.1.0",
"description": "Create functions for operating on a list of DOM elements",

@@ -14,8 +14,6 @@ "main": "dist/bundle.js",

"devDependencies": {
"babel-preset-es2015-rollup": "^1.2.0",
"rollup-plugin-babel": "^2.6.1",
"rollup-plugin-buble": "^0.15.0",
"rollup-plugin-commonjs": "^5.0.5",
"rollup-plugin-node-resolve": "^2.0.0",
"rollup-plugin-uglify": "^1.0.1",
"tape": "^4.6.2",
"uglify-js": "^2.7.4"

@@ -22,0 +20,0 @@ },

@@ -56,5 +56,18 @@ Install

Available imports
-----------------
Selector imports
----------------
### select(selector|element)
Select an element with `selector`, or just return `element`.
### selectAll(selector|array)
Select all elements using `selector`, select one element for each selector in `array`.
If `array` has any elements in it those get returned unmodified.
List imports
------------
- indexOfElement(array, element)

@@ -61,0 +74,0 @@ - hasElement(array, element)

"use strict";
//import babel from 'rollup-plugin-babel';
const babel = require('rollup-plugin-babel');
//const babel = require('rollup-plugin-babel');
const rollup = require('rollup');
const uglify = require('rollup-plugin-uglify');
const buble = require('rollup-plugin-buble');
const nodeResolve = require('rollup-plugin-node-resolve');

@@ -15,3 +15,3 @@ const commonjs = require('rollup-plugin-commonjs');

entry: 'src/index.js',
plugins: [babel()],
plugins: [buble()],
external: external

@@ -38,3 +38,2 @@ }).then((bundle)=>{

plugins: [
babel(),
nodeResolve({

@@ -44,3 +43,4 @@ jsnext: true,

}),
commonjs()
commonjs(),
buble()
],

@@ -71,7 +71,7 @@ }).then((bundle)=>{

plugins: [
babel(),
nodeResolve({
main: true
}),
commonjs()
commonjs(),
buble()
]

@@ -78,0 +78,0 @@ }).then(bundle=>{

import isElement from 'iselement';
import arrayFrom from 'array-from';
import isArray from 'is-array';
export { select, selectAll } from './lib/select.js';
export function indexOfElement(elements, element){

@@ -50,3 +53,3 @@ element = resolveElement(element, true);

function pushElements(elements, toAdd){
for(let i=0; i<toAdd.length; i++){

@@ -53,0 +56,0 @@ if(!hasElement(elements, toAdd[i]))

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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