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

@pluginjs/dom

Package Overview
Dependencies
Maintainers
2
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@pluginjs/dom - npm Package Compare versions

Comparing version 0.7.2 to 0.7.3

dist/dom.umd.js

78

dist/dom.common.js
/*!
* @pluginjs/dom v0.7.2 (https://pluginjs.com)
* @pluginjs/dom v0.7.3 (https://pluginjs.com)
* Copyright 2018 Creation Studio Limited

@@ -13,3 +13,45 @@ * Released under the GPL-3.0 License.

const parseHTML = (...args) => {
function _slicedToArray(arr, i) {
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest();
}
function _arrayWithHoles(arr) {
if (Array.isArray(arr)) return arr;
}
function _iterableToArrayLimit(arr, i) {
var _arr = [];
var _n = true;
var _d = false;
var _e = undefined;
try {
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
_arr.push(_s.value);
if (i && _arr.length === i) break;
}
} catch (err) {
_d = true;
_e = err;
} finally {
try {
if (!_n && _i["return"] != null) _i["return"]();
} finally {
if (_d) throw _e;
}
}
return _arr;
}
function _nonIterableRest() {
throw new TypeError("Invalid attempt to destructure non-iterable instance");
}
const parseHTML = function parseHTML() {
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
const htmlString = Array.isArray(args[0]) ? args[0].reduce((result, str, index) => result + args[index] + str) : args[0]; // if('content' in document.createElement('template')) {

@@ -45,4 +87,10 @@ // const temp = document.createElement('template')

const query = (selector, parent = document) => parent.querySelector(selector);
const queryAll = (selector, parent = document) => Array.from(parent.querySelectorAll(selector));
const query = function query(selector) {
let parent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : document;
return parent.querySelector(selector);
};
const queryAll = function queryAll(selector) {
let parent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : document;
return Array.from(parent.querySelectorAll(selector));
};
const find = utils.curry((selector, parent) => parent.querySelector(selector));

@@ -245,3 +293,9 @@ const findAll = utils.curry((selector, parent) => Array.from(parent.querySelectorAll(selector)));

} else {
Object.entries(key).forEach(([k, v]) => setData(k, v, el));
Object.entries(key).forEach((_ref) => {
let _ref2 = _slicedToArray(_ref, 2),
k = _ref2[0],
v = _ref2[1];
return setData(k, v, el);
});
}

@@ -267,3 +321,9 @@

} else {
Object.entries(args).forEach(([key, value]) => el.setAttribute(key, value));
Object.entries(args).forEach((_ref3) => {
let _ref4 = _slicedToArray(_ref3, 2),
key = _ref4[0],
value = _ref4[1];
return el.setAttribute(key, value);
});
}

@@ -306,3 +366,7 @@

} else {
Object.entries(props).forEach(([key, value]) => {
Object.entries(props).forEach((_ref5) => {
let _ref6 = _slicedToArray(_ref5, 2),
key = _ref6[0],
value = _ref6[1];
el[propMap[key] || key] = value;

@@ -309,0 +373,0 @@ });

4

dist/dom.common.min.js
/*!
* @pluginjs/dom v0.7.2 (https://pluginjs.com)
* @pluginjs/dom v0.7.3 (https://pluginjs.com)
* Copyright 2018 Creation Studio Limited
* Released under the GPL-3.0 License.
*/
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var utils=require("@pluginjs/utils"),is=require("@pluginjs/is");const parseHTML=(...e)=>{const t=Array.isArray(e[0])?e[0].reduce((t,r,i)=>t+e[i]+r):e[0],r=document.createElement("div");if(r.innerHTML=t,1===r.children.length)return r.children[0];const i=document.createDocumentFragment();if(r.children.length)for(;r.children.length>0;)i.appendChild(r.children[0]);else for(;r.childNodes.length>0;)i.appendChild(r.childNodes[0]);return i},query=(e,t=document)=>t.querySelector(e),queryAll=(e,t=document)=>Array.from(t.querySelectorAll(e)),find=utils.curry((e,t)=>t.querySelector(e)),findAll=utils.curry((e,t)=>Array.from(t.querySelectorAll(e))),has=(e,t)=>is.isString(e)?Boolean(queryAll(e,t).length):t.contains(e),contents=e=>"IFRAME"===e.tagName?[e.contentDocument]:e.childNodes,children=(e,t)=>(is.isString(e)||void 0!==t||(t=e,e=void 0),is.isElement(t)?is.isString(e)?Array.from(t.children).filter(t=>t.matches(e)):Array.from(t.children):[]),siblings=(e,t)=>(is.isString(e)||void 0!==t||(t=e,e=void 0),is.isElement(t)?children(e,t.parentNode).filter(e=>e!==t):[]),prev=e=>e.previousElementSibling,next=e=>e.nextElementSibling,prevWith=utils.curry((e,t)=>{const r=t.previousElementSibling;return r?e(r)?r:prevWith(e,r):null}),nextWith=utils.curry((e,t)=>{const r=t.nextElementSibling;return r?e(r)?r:nextWith(e,r):null}),parent=e=>e.parentNode,parents=(e,t)=>{is.isString(e)||void 0!==t||(t=e,e=void 0);const r=[];let i=t;for(;is.isElement(i)&&i.parentNode&&i!==document.body.parentNode;)i=i.parentNode,(!e||e&&i.matches(e))&&r.push(i);return r},parentWith=utils.curry((e,t)=>{const r=t.parentNode;return!(!r||r===document)&&(e(r)?r:parentWith(e,r))}),closest=(e,t)=>t.matches(e)?t:parentWith(t=>t.matches(e),t),offsetParent=e=>{let t=e.offsetParent;for(;t&&"static"===t.style.position;)t=t.offsetParent;return t||document.documentElement},scrollParent=e=>parentWith(e=>e.scrollHeight>e.clientHeight,e),indexOf=e=>[...e.parentElement.children].indexOf(e),dataStore="__pluginjsData",getCachedData=e=>e[dataStore]=e[dataStore]||{},getData=(e,t)=>{is.isElement(e)&&void 0===t&&(t=e,e=void 0);const r=getCachedData(t);if(e){if(!(e in r)){let i=t.dataset[e]||t.dataset[utils.camelize(e,!1)];if(void 0!==i){try{i=JSON.parse(i)}catch(e){}r[e]=i}}return r[e]}return r},setData=(e,t,r)=>(getCachedData(r)[e]=t,r),removeData=(e,t)=>(is.isElement(e)&&void 0===t&&(t=e,e=void 0),void 0===e?delete t[dataStore]:delete getCachedData(t)[e],t),hasData=e=>dataStore in e&&!is.isEmptyObject(e[dataStore]),data=utils.curryWith((e,t,r)=>{if(is.isElement(t)&&void 0===r&&(r=t,t=void 0),"string"==typeof e){if(void 0===t)return getData(e,r);setData(e,t,r)}else Object.entries(e).forEach(([e,t])=>setData(e,t,r));return r},is.isElement),attr=utils.curryWith((e,t,r)=>{if(is.isElement(t)&&void 0===r&&(r=t,t=void 0),"string"==typeof e){if(void 0===t)return r.getAttribute(e);r.setAttribute(e,t)}else Object.entries(e).forEach(([e,t])=>r.setAttribute(e,t));return r},is.isElement),removeAttr=utils.curry((e,t)=>(e.split(" ").forEach(e=>{t.removeAttribute(e)}),t)),propMap={tabindex:"tabIndex",readonly:"readOnly",for:"htmlFor",class:"className",maxlength:"maxLength",cellspacing:"cellSpacing",cellpadding:"cellPadding",rowspan:"rowSpan",colspan:"colSpan",usemap:"useMap",frameborder:"frameBorder",contenteditable:"contentEditable"},prop=utils.curryWith((e,t,r)=>{if(is.isElement(t)&&void 0===r&&(r=t,t=void 0),"string"==typeof e){if(void 0===t)return r[propMap[e]||e];r[propMap[e]||e]=t}else Object.entries(e).forEach(([e,t])=>{r[propMap[e]||e]=t});return r},is.isElement),removeProp=utils.curry((e,t)=>(e.split(" ").forEach(e=>{delete t[e=propMap[e]||e]}),t)),clone=utils.curry(e=>e.cloneNode(!0)),detach=utils.curry(e=>(e.parentNode&&e.parentNode.removeChild(e),e)),remove=utils.curry(e=>e.remove()),empty=utils.curry(e=>{for(;e.lastChild;)e.removeChild(e.lastChild);return e}),html=utils.curryWith((e,t)=>(is.isString(e)||void 0!==t||(t=e,e=void 0),void 0===e?t.innerHTML:(t.innerHTML=e,t)),is.isElement),text=utils.curryWith((e,t)=>(is.isString(e)||void 0!==t||(t=e,e=void 0),void 0===e?t.textContent:(t.textContent=e,t)),is.isElement),append=utils.curry((e,t)=>(is.isString(e)?t.insertAdjacentHTML("beforeend",e):t.append(e),t)),appendTo=utils.curry((e,t)=>(is.isString(e)&&(e=parseHTML(e)),t.append(e),e)),prepend=utils.curry((e,t)=>(is.isString(e)?t.insertAdjacentHTML("afterbegin",e):t.prepend(e),t)),prependTo=utils.curry((e,t)=>(is.isString(e)&&(e=parseHTML(e)),t.prepend(e),e)),before=utils.curry((e,t)=>(is.isString(e)?t.insertAdjacentHTML("beforebegin",e):t.parentNode.insertBefore(e,t),t)),insertBefore=utils.curry((e,t)=>(is.isString(e)&&(e=parseHTML(e)),NodeList.prototype.isPrototypeOf(e)?e.forEach(e=>{t.parentNode.insertBefore(e,t)}):t.parentNode.insertBefore(e,t),e)),after=utils.curry((e,t)=>(is.isString(e)?t.insertAdjacentHTML("afterend",e):t.parentNode.insertBefore(e,t.nextElementSibling),t)),insertAfter=utils.curry((e,t)=>(is.isString(e)&&(e=parseHTML(e)),NodeList.prototype.isPrototypeOf(e)?e.forEach(e=>{t.parentNode.insertBefore(e,t.nextElementSibling)}):t.parentNode.insertBefore(e,t.nextElementSibling),e)),wrap=utils.curry((e,t)=>(is.isString(e)&&(e=parseHTML(e)),insertBefore(e,t),append(t,e),e)),wrapInner=utils.curry((e,t)=>(is.isString(e)&&(e=parseHTML(e)),e.innerHTML=t.innerHTML,t.innerHTML="",t.append(e),t)),wrapAll=utils.curry((e,t)=>(is.isString(e)&&(e=parseHTML(e)),insertBefore(e,t[0]),e.append(...t),e)),unwrap=utils.curryWith((e,t)=>{is.isString(e)||void 0!==t||(t=e,e=void 0);const r=t.parentNode;return e&&!r.matches(e)||(children(r).forEach(e=>{insertBefore(e,r)}),r.remove()),t},is.isElement),replace=utils.curry((e,t)=>(is.isString(e)&&(e=parseHTML(e)),t.parentNode.replaceChild(e,t),t.remove(),e));exports.parseHTML=parseHTML,exports.query=query,exports.queryAll=queryAll,exports.find=find,exports.findAll=findAll,exports.has=has,exports.contents=contents,exports.children=children,exports.siblings=siblings,exports.prev=prev,exports.next=next,exports.prevWith=prevWith,exports.nextWith=nextWith,exports.parent=parent,exports.parents=parents,exports.parentWith=parentWith,exports.closest=closest,exports.offsetParent=offsetParent,exports.scrollParent=scrollParent,exports.indexOf=indexOf,exports.getData=getData,exports.setData=setData,exports.removeData=removeData,exports.hasData=hasData,exports.data=data,exports.attr=attr,exports.removeAttr=removeAttr,exports.prop=prop,exports.removeProp=removeProp,exports.clone=clone,exports.detach=detach,exports.remove=remove,exports.empty=empty,exports.html=html,exports.text=text,exports.append=append,exports.appendTo=appendTo,exports.prepend=prepend,exports.prependTo=prependTo,exports.before=before,exports.insertBefore=insertBefore,exports.after=after,exports.insertAfter=insertAfter,exports.wrap=wrap,exports.wrapInner=wrapInner,exports.wrapAll=wrapAll,exports.unwrap=unwrap,exports.replace=replace;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var utils=require("@pluginjs/utils"),is=require("@pluginjs/is");function _slicedToArray(e,t){return _arrayWithHoles(e)||_iterableToArrayLimit(e,t)||_nonIterableRest()}function _arrayWithHoles(e){if(Array.isArray(e))return e}function _iterableToArrayLimit(e,t){var r=[],i=!0,n=!1,s=void 0;try{for(var o,a=e[Symbol.iterator]();!(i=(o=a.next()).done)&&(r.push(o.value),!t||r.length!==t);i=!0);}catch(e){n=!0,s=e}finally{try{i||null==a.return||a.return()}finally{if(n)throw s}}return r}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}const parseHTML=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];const i=Array.isArray(t[0])?t[0].reduce((e,r,i)=>e+t[i]+r):t[0],n=document.createElement("div");if(n.innerHTML=i,1===n.children.length)return n.children[0];const s=document.createDocumentFragment();if(n.children.length)for(;n.children.length>0;)s.appendChild(n.children[0]);else for(;n.childNodes.length>0;)s.appendChild(n.childNodes[0]);return s},query=function(e){return(arguments.length>1&&void 0!==arguments[1]?arguments[1]:document).querySelector(e)},queryAll=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:document;return Array.from(t.querySelectorAll(e))},find=utils.curry((e,t)=>t.querySelector(e)),findAll=utils.curry((e,t)=>Array.from(t.querySelectorAll(e))),has=(e,t)=>is.isString(e)?Boolean(queryAll(e,t).length):t.contains(e),contents=e=>"IFRAME"===e.tagName?[e.contentDocument]:e.childNodes,children=(e,t)=>(is.isString(e)||void 0!==t||(t=e,e=void 0),is.isElement(t)?is.isString(e)?Array.from(t.children).filter(t=>t.matches(e)):Array.from(t.children):[]),siblings=(e,t)=>(is.isString(e)||void 0!==t||(t=e,e=void 0),is.isElement(t)?children(e,t.parentNode).filter(e=>e!==t):[]),prev=e=>e.previousElementSibling,next=e=>e.nextElementSibling,prevWith=utils.curry((e,t)=>{const r=t.previousElementSibling;return r?e(r)?r:prevWith(e,r):null}),nextWith=utils.curry((e,t)=>{const r=t.nextElementSibling;return r?e(r)?r:nextWith(e,r):null}),parent=e=>e.parentNode,parents=(e,t)=>{is.isString(e)||void 0!==t||(t=e,e=void 0);const r=[];let i=t;for(;is.isElement(i)&&i.parentNode&&i!==document.body.parentNode;)i=i.parentNode,(!e||e&&i.matches(e))&&r.push(i);return r},parentWith=utils.curry((e,t)=>{const r=t.parentNode;return!(!r||r===document)&&(e(r)?r:parentWith(e,r))}),closest=(e,t)=>t.matches(e)?t:parentWith(t=>t.matches(e),t),offsetParent=e=>{let t=e.offsetParent;for(;t&&"static"===t.style.position;)t=t.offsetParent;return t||document.documentElement},scrollParent=e=>parentWith(e=>e.scrollHeight>e.clientHeight,e),indexOf=e=>[...e.parentElement.children].indexOf(e),dataStore="__pluginjsData",getCachedData=e=>e[dataStore]=e[dataStore]||{},getData=(e,t)=>{is.isElement(e)&&void 0===t&&(t=e,e=void 0);const r=getCachedData(t);if(e){if(!(e in r)){let i=t.dataset[e]||t.dataset[utils.camelize(e,!1)];if(void 0!==i){try{i=JSON.parse(i)}catch(e){}r[e]=i}}return r[e]}return r},setData=(e,t,r)=>(getCachedData(r)[e]=t,r),removeData=(e,t)=>(is.isElement(e)&&void 0===t&&(t=e,e=void 0),void 0===e?delete t[dataStore]:delete getCachedData(t)[e],t),hasData=e=>dataStore in e&&!is.isEmptyObject(e[dataStore]),data=utils.curryWith((e,t,r)=>{if(is.isElement(t)&&void 0===r&&(r=t,t=void 0),"string"==typeof e){if(void 0===t)return getData(e,r);setData(e,t,r)}else Object.entries(e).forEach(e=>{let t=_slicedToArray(e,2),i=t[0],n=t[1];return setData(i,n,r)});return r},is.isElement),attr=utils.curryWith((e,t,r)=>{if(is.isElement(t)&&void 0===r&&(r=t,t=void 0),"string"==typeof e){if(void 0===t)return r.getAttribute(e);r.setAttribute(e,t)}else Object.entries(e).forEach(e=>{let t=_slicedToArray(e,2),i=t[0],n=t[1];return r.setAttribute(i,n)});return r},is.isElement),removeAttr=utils.curry((e,t)=>(e.split(" ").forEach(e=>{t.removeAttribute(e)}),t)),propMap={tabindex:"tabIndex",readonly:"readOnly",for:"htmlFor",class:"className",maxlength:"maxLength",cellspacing:"cellSpacing",cellpadding:"cellPadding",rowspan:"rowSpan",colspan:"colSpan",usemap:"useMap",frameborder:"frameBorder",contenteditable:"contentEditable"},prop=utils.curryWith((e,t,r)=>{if(is.isElement(t)&&void 0===r&&(r=t,t=void 0),"string"==typeof e){if(void 0===t)return r[propMap[e]||e];r[propMap[e]||e]=t}else Object.entries(e).forEach(e=>{let t=_slicedToArray(e,2),i=t[0],n=t[1];r[propMap[i]||i]=n});return r},is.isElement),removeProp=utils.curry((e,t)=>(e.split(" ").forEach(e=>{delete t[e=propMap[e]||e]}),t)),clone=utils.curry(e=>e.cloneNode(!0)),detach=utils.curry(e=>(e.parentNode&&e.parentNode.removeChild(e),e)),remove=utils.curry(e=>e.remove()),empty=utils.curry(e=>{for(;e.lastChild;)e.removeChild(e.lastChild);return e}),html=utils.curryWith((e,t)=>(is.isString(e)||void 0!==t||(t=e,e=void 0),void 0===e?t.innerHTML:(t.innerHTML=e,t)),is.isElement),text=utils.curryWith((e,t)=>(is.isString(e)||void 0!==t||(t=e,e=void 0),void 0===e?t.textContent:(t.textContent=e,t)),is.isElement),append=utils.curry((e,t)=>(is.isString(e)?t.insertAdjacentHTML("beforeend",e):t.append(e),t)),appendTo=utils.curry((e,t)=>(is.isString(e)&&(e=parseHTML(e)),t.append(e),e)),prepend=utils.curry((e,t)=>(is.isString(e)?t.insertAdjacentHTML("afterbegin",e):t.prepend(e),t)),prependTo=utils.curry((e,t)=>(is.isString(e)&&(e=parseHTML(e)),t.prepend(e),e)),before=utils.curry((e,t)=>(is.isString(e)?t.insertAdjacentHTML("beforebegin",e):t.parentNode.insertBefore(e,t),t)),insertBefore=utils.curry((e,t)=>(is.isString(e)&&(e=parseHTML(e)),NodeList.prototype.isPrototypeOf(e)?e.forEach(e=>{t.parentNode.insertBefore(e,t)}):t.parentNode.insertBefore(e,t),e)),after=utils.curry((e,t)=>(is.isString(e)?t.insertAdjacentHTML("afterend",e):t.parentNode.insertBefore(e,t.nextElementSibling),t)),insertAfter=utils.curry((e,t)=>(is.isString(e)&&(e=parseHTML(e)),NodeList.prototype.isPrototypeOf(e)?e.forEach(e=>{t.parentNode.insertBefore(e,t.nextElementSibling)}):t.parentNode.insertBefore(e,t.nextElementSibling),e)),wrap=utils.curry((e,t)=>(is.isString(e)&&(e=parseHTML(e)),insertBefore(e,t),append(t,e),e)),wrapInner=utils.curry((e,t)=>(is.isString(e)&&(e=parseHTML(e)),e.innerHTML=t.innerHTML,t.innerHTML="",t.append(e),t)),wrapAll=utils.curry((e,t)=>(is.isString(e)&&(e=parseHTML(e)),insertBefore(e,t[0]),e.append(...t),e)),unwrap=utils.curryWith((e,t)=>{is.isString(e)||void 0!==t||(t=e,e=void 0);const r=t.parentNode;return e&&!r.matches(e)||(children(r).forEach(e=>{insertBefore(e,r)}),r.remove()),t},is.isElement),replace=utils.curry((e,t)=>(is.isString(e)&&(e=parseHTML(e)),t.parentNode.replaceChild(e,t),t.remove(),e));exports.parseHTML=parseHTML,exports.query=query,exports.queryAll=queryAll,exports.find=find,exports.findAll=findAll,exports.has=has,exports.contents=contents,exports.children=children,exports.siblings=siblings,exports.prev=prev,exports.next=next,exports.prevWith=prevWith,exports.nextWith=nextWith,exports.parent=parent,exports.parents=parents,exports.parentWith=parentWith,exports.closest=closest,exports.offsetParent=offsetParent,exports.scrollParent=scrollParent,exports.indexOf=indexOf,exports.getData=getData,exports.setData=setData,exports.removeData=removeData,exports.hasData=hasData,exports.data=data,exports.attr=attr,exports.removeAttr=removeAttr,exports.prop=prop,exports.removeProp=removeProp,exports.clone=clone,exports.detach=detach,exports.remove=remove,exports.empty=empty,exports.html=html,exports.text=text,exports.append=append,exports.appendTo=appendTo,exports.prepend=prepend,exports.prependTo=prependTo,exports.before=before,exports.insertBefore=insertBefore,exports.after=after,exports.insertAfter=insertAfter,exports.wrap=wrap,exports.wrapInner=wrapInner,exports.wrapAll=wrapAll,exports.unwrap=unwrap,exports.replace=replace;
/*!
* @pluginjs/dom v0.7.2 (https://pluginjs.com)
* @pluginjs/dom v0.7.3 (https://pluginjs.com)
* Copyright 2018 Creation Studio Limited

@@ -9,3 +9,45 @@ * Released under the GPL-3.0 License.

const parseHTML = (...args) => {
function _slicedToArray(arr, i) {
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest();
}
function _arrayWithHoles(arr) {
if (Array.isArray(arr)) return arr;
}
function _iterableToArrayLimit(arr, i) {
var _arr = [];
var _n = true;
var _d = false;
var _e = undefined;
try {
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
_arr.push(_s.value);
if (i && _arr.length === i) break;
}
} catch (err) {
_d = true;
_e = err;
} finally {
try {
if (!_n && _i["return"] != null) _i["return"]();
} finally {
if (_d) throw _e;
}
}
return _arr;
}
function _nonIterableRest() {
throw new TypeError("Invalid attempt to destructure non-iterable instance");
}
const parseHTML = function parseHTML() {
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
const htmlString = Array.isArray(args[0]) ? args[0].reduce((result, str, index) => result + args[index] + str) : args[0]; // if('content' in document.createElement('template')) {

@@ -41,4 +83,10 @@ // const temp = document.createElement('template')

const query = (selector, parent = document) => parent.querySelector(selector);
const queryAll = (selector, parent = document) => Array.from(parent.querySelectorAll(selector));
const query = function query(selector) {
let parent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : document;
return parent.querySelector(selector);
};
const queryAll = function queryAll(selector) {
let parent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : document;
return Array.from(parent.querySelectorAll(selector));
};
const find = curry((selector, parent) => parent.querySelector(selector));

@@ -241,3 +289,9 @@ const findAll = curry((selector, parent) => Array.from(parent.querySelectorAll(selector)));

} else {
Object.entries(key).forEach(([k, v]) => setData(k, v, el));
Object.entries(key).forEach((_ref) => {
let _ref2 = _slicedToArray(_ref, 2),
k = _ref2[0],
v = _ref2[1];
return setData(k, v, el);
});
}

@@ -263,3 +317,9 @@

} else {
Object.entries(args).forEach(([key, value]) => el.setAttribute(key, value));
Object.entries(args).forEach((_ref3) => {
let _ref4 = _slicedToArray(_ref3, 2),
key = _ref4[0],
value = _ref4[1];
return el.setAttribute(key, value);
});
}

@@ -302,3 +362,7 @@

} else {
Object.entries(props).forEach(([key, value]) => {
Object.entries(props).forEach((_ref5) => {
let _ref6 = _slicedToArray(_ref5, 2),
key = _ref6[0],
value = _ref6[1];
el[propMap[key] || key] = value;

@@ -305,0 +369,0 @@ });

/*!
* @pluginjs/dom v0.7.2 (https://pluginjs.com)
* @pluginjs/dom v0.7.3 (https://pluginjs.com)
* Copyright 2018 Creation Studio Limited
* Released under the GPL-3.0 License.
*/
import{curry,curryWith,camelize}from"@pluginjs/utils";import{isString,isElement,isEmptyObject}from"@pluginjs/is";const parseHTML=(...e)=>{const r=Array.isArray(e[0])?e[0].reduce((r,t,n)=>r+e[n]+t):e[0],t=document.createElement("div");if(t.innerHTML=r,1===t.children.length)return t.children[0];const n=document.createDocumentFragment();if(t.children.length)for(;t.children.length>0;)n.appendChild(t.children[0]);else for(;t.childNodes.length>0;)n.appendChild(t.childNodes[0]);return n},query=(e,r=document)=>r.querySelector(e),queryAll=(e,r=document)=>Array.from(r.querySelectorAll(e)),find=curry((e,r)=>r.querySelector(e)),findAll=curry((e,r)=>Array.from(r.querySelectorAll(e))),has=(e,r)=>isString(e)?Boolean(queryAll(e,r).length):r.contains(e),contents=e=>"IFRAME"===e.tagName?[e.contentDocument]:e.childNodes,children=(e,r)=>(isString(e)||void 0!==r||(r=e,e=void 0),isElement(r)?isString(e)?Array.from(r.children).filter(r=>r.matches(e)):Array.from(r.children):[]),siblings=(e,r)=>(isString(e)||void 0!==r||(r=e,e=void 0),isElement(r)?children(e,r.parentNode).filter(e=>e!==r):[]),prev=e=>e.previousElementSibling,next=e=>e.nextElementSibling,prevWith=curry((e,r)=>{const t=r.previousElementSibling;return t?e(t)?t:prevWith(e,t):null}),nextWith=curry((e,r)=>{const t=r.nextElementSibling;return t?e(t)?t:nextWith(e,t):null}),parent=e=>e.parentNode,parents=(e,r)=>{isString(e)||void 0!==r||(r=e,e=void 0);const t=[];let n=r;for(;isElement(n)&&n.parentNode&&n!==document.body.parentNode;)n=n.parentNode,(!e||e&&n.matches(e))&&t.push(n);return t},parentWith=curry((e,r)=>{const t=r.parentNode;return!(!t||t===document)&&(e(t)?t:parentWith(e,t))}),closest=(e,r)=>r.matches(e)?r:parentWith(r=>r.matches(e),r),offsetParent=e=>{let r=e.offsetParent;for(;r&&"static"===r.style.position;)r=r.offsetParent;return r||document.documentElement},scrollParent=e=>parentWith(e=>e.scrollHeight>e.clientHeight,e),indexOf=e=>[...e.parentElement.children].indexOf(e),dataStore="__pluginjsData",getCachedData=e=>e[dataStore]=e[dataStore]||{},getData=(e,r)=>{isElement(e)&&void 0===r&&(r=e,e=void 0);const t=getCachedData(r);if(e){if(!(e in t)){let n=r.dataset[e]||r.dataset[camelize(e,!1)];if(void 0!==n){try{n=JSON.parse(n)}catch(e){}t[e]=n}}return t[e]}return t},setData=(e,r,t)=>(getCachedData(t)[e]=r,t),removeData=(e,r)=>(isElement(e)&&void 0===r&&(r=e,e=void 0),void 0===e?delete r[dataStore]:delete getCachedData(r)[e],r),hasData=e=>dataStore in e&&!isEmptyObject(e[dataStore]),data=curryWith((e,r,t)=>{if(isElement(r)&&void 0===t&&(t=r,r=void 0),"string"==typeof e){if(void 0===r)return getData(e,t);setData(e,r,t)}else Object.entries(e).forEach(([e,r])=>setData(e,r,t));return t},isElement),attr=curryWith((e,r,t)=>{if(isElement(r)&&void 0===t&&(t=r,r=void 0),"string"==typeof e){if(void 0===r)return t.getAttribute(e);t.setAttribute(e,r)}else Object.entries(e).forEach(([e,r])=>t.setAttribute(e,r));return t},isElement),removeAttr=curry((e,r)=>(e.split(" ").forEach(e=>{r.removeAttribute(e)}),r)),propMap={tabindex:"tabIndex",readonly:"readOnly",for:"htmlFor",class:"className",maxlength:"maxLength",cellspacing:"cellSpacing",cellpadding:"cellPadding",rowspan:"rowSpan",colspan:"colSpan",usemap:"useMap",frameborder:"frameBorder",contenteditable:"contentEditable"},prop=curryWith((e,r,t)=>{if(isElement(r)&&void 0===t&&(t=r,r=void 0),"string"==typeof e){if(void 0===r)return t[propMap[e]||e];t[propMap[e]||e]=r}else Object.entries(e).forEach(([e,r])=>{t[propMap[e]||e]=r});return t},isElement),removeProp=curry((e,r)=>(e.split(" ").forEach(e=>{delete r[e=propMap[e]||e]}),r)),clone=curry(e=>e.cloneNode(!0)),detach=curry(e=>(e.parentNode&&e.parentNode.removeChild(e),e)),remove=curry(e=>e.remove()),empty=curry(e=>{for(;e.lastChild;)e.removeChild(e.lastChild);return e}),html=curryWith((e,r)=>(isString(e)||void 0!==r||(r=e,e=void 0),void 0===e?r.innerHTML:(r.innerHTML=e,r)),isElement),text=curryWith((e,r)=>(isString(e)||void 0!==r||(r=e,e=void 0),void 0===e?r.textContent:(r.textContent=e,r)),isElement),append=curry((e,r)=>(isString(e)?r.insertAdjacentHTML("beforeend",e):r.append(e),r)),appendTo=curry((e,r)=>(isString(e)&&(e=parseHTML(e)),r.append(e),e)),prepend=curry((e,r)=>(isString(e)?r.insertAdjacentHTML("afterbegin",e):r.prepend(e),r)),prependTo=curry((e,r)=>(isString(e)&&(e=parseHTML(e)),r.prepend(e),e)),before=curry((e,r)=>(isString(e)?r.insertAdjacentHTML("beforebegin",e):r.parentNode.insertBefore(e,r),r)),insertBefore=curry((e,r)=>(isString(e)&&(e=parseHTML(e)),NodeList.prototype.isPrototypeOf(e)?e.forEach(e=>{r.parentNode.insertBefore(e,r)}):r.parentNode.insertBefore(e,r),e)),after=curry((e,r)=>(isString(e)?r.insertAdjacentHTML("afterend",e):r.parentNode.insertBefore(e,r.nextElementSibling),r)),insertAfter=curry((e,r)=>(isString(e)&&(e=parseHTML(e)),NodeList.prototype.isPrototypeOf(e)?e.forEach(e=>{r.parentNode.insertBefore(e,r.nextElementSibling)}):r.parentNode.insertBefore(e,r.nextElementSibling),e)),wrap=curry((e,r)=>(isString(e)&&(e=parseHTML(e)),insertBefore(e,r),append(r,e),e)),wrapInner=curry((e,r)=>(isString(e)&&(e=parseHTML(e)),e.innerHTML=r.innerHTML,r.innerHTML="",r.append(e),r)),wrapAll=curry((e,r)=>(isString(e)&&(e=parseHTML(e)),insertBefore(e,r[0]),e.append(...r),e)),unwrap=curryWith((e,r)=>{isString(e)||void 0!==r||(r=e,e=void 0);const t=r.parentNode;return e&&!t.matches(e)||(children(t).forEach(e=>{insertBefore(e,t)}),t.remove()),r},isElement),replace=curry((e,r)=>(isString(e)&&(e=parseHTML(e)),r.parentNode.replaceChild(e,r),r.remove(),e));export{parseHTML,query,queryAll,find,findAll,has,contents,children,siblings,prev,next,prevWith,nextWith,parent,parents,parentWith,closest,offsetParent,scrollParent,indexOf,getData,setData,removeData,hasData,data,attr,removeAttr,prop,removeProp,clone,detach,remove,empty,html,text,append,appendTo,prepend,prependTo,before,insertBefore,after,insertAfter,wrap,wrapInner,wrapAll,unwrap,replace};
import{curry,curryWith,camelize}from"@pluginjs/utils";import{isString,isElement,isEmptyObject}from"@pluginjs/is";function _slicedToArray(e,r){return _arrayWithHoles(e)||_iterableToArrayLimit(e,r)||_nonIterableRest()}function _arrayWithHoles(e){if(Array.isArray(e))return e}function _iterableToArrayLimit(e,r){var t=[],n=!0,i=!1,a=void 0;try{for(var o,l=e[Symbol.iterator]();!(n=(o=l.next()).done)&&(t.push(o.value),!r||t.length!==r);n=!0);}catch(e){i=!0,a=e}finally{try{n||null==l.return||l.return()}finally{if(i)throw a}}return t}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}const parseHTML=function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++)r[t]=arguments[t];const n=Array.isArray(r[0])?r[0].reduce((e,t,n)=>e+r[n]+t):r[0],i=document.createElement("div");if(i.innerHTML=n,1===i.children.length)return i.children[0];const a=document.createDocumentFragment();if(i.children.length)for(;i.children.length>0;)a.appendChild(i.children[0]);else for(;i.childNodes.length>0;)a.appendChild(i.childNodes[0]);return a},query=function(e){return(arguments.length>1&&void 0!==arguments[1]?arguments[1]:document).querySelector(e)},queryAll=function(e){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:document;return Array.from(r.querySelectorAll(e))},find=curry((e,r)=>r.querySelector(e)),findAll=curry((e,r)=>Array.from(r.querySelectorAll(e))),has=(e,r)=>isString(e)?Boolean(queryAll(e,r).length):r.contains(e),contents=e=>"IFRAME"===e.tagName?[e.contentDocument]:e.childNodes,children=(e,r)=>(isString(e)||void 0!==r||(r=e,e=void 0),isElement(r)?isString(e)?Array.from(r.children).filter(r=>r.matches(e)):Array.from(r.children):[]),siblings=(e,r)=>(isString(e)||void 0!==r||(r=e,e=void 0),isElement(r)?children(e,r.parentNode).filter(e=>e!==r):[]),prev=e=>e.previousElementSibling,next=e=>e.nextElementSibling,prevWith=curry((e,r)=>{const t=r.previousElementSibling;return t?e(t)?t:prevWith(e,t):null}),nextWith=curry((e,r)=>{const t=r.nextElementSibling;return t?e(t)?t:nextWith(e,t):null}),parent=e=>e.parentNode,parents=(e,r)=>{isString(e)||void 0!==r||(r=e,e=void 0);const t=[];let n=r;for(;isElement(n)&&n.parentNode&&n!==document.body.parentNode;)n=n.parentNode,(!e||e&&n.matches(e))&&t.push(n);return t},parentWith=curry((e,r)=>{const t=r.parentNode;return!(!t||t===document)&&(e(t)?t:parentWith(e,t))}),closest=(e,r)=>r.matches(e)?r:parentWith(r=>r.matches(e),r),offsetParent=e=>{let r=e.offsetParent;for(;r&&"static"===r.style.position;)r=r.offsetParent;return r||document.documentElement},scrollParent=e=>parentWith(e=>e.scrollHeight>e.clientHeight,e),indexOf=e=>[...e.parentElement.children].indexOf(e),dataStore="__pluginjsData",getCachedData=e=>e[dataStore]=e[dataStore]||{},getData=(e,r)=>{isElement(e)&&void 0===r&&(r=e,e=void 0);const t=getCachedData(r);if(e){if(!(e in t)){let n=r.dataset[e]||r.dataset[camelize(e,!1)];if(void 0!==n){try{n=JSON.parse(n)}catch(e){}t[e]=n}}return t[e]}return t},setData=(e,r,t)=>(getCachedData(t)[e]=r,t),removeData=(e,r)=>(isElement(e)&&void 0===r&&(r=e,e=void 0),void 0===e?delete r[dataStore]:delete getCachedData(r)[e],r),hasData=e=>dataStore in e&&!isEmptyObject(e[dataStore]),data=curryWith((e,r,t)=>{if(isElement(r)&&void 0===t&&(t=r,r=void 0),"string"==typeof e){if(void 0===r)return getData(e,t);setData(e,r,t)}else Object.entries(e).forEach(e=>{let r=_slicedToArray(e,2),n=r[0],i=r[1];return setData(n,i,t)});return t},isElement),attr=curryWith((e,r,t)=>{if(isElement(r)&&void 0===t&&(t=r,r=void 0),"string"==typeof e){if(void 0===r)return t.getAttribute(e);t.setAttribute(e,r)}else Object.entries(e).forEach(e=>{let r=_slicedToArray(e,2),n=r[0],i=r[1];return t.setAttribute(n,i)});return t},isElement),removeAttr=curry((e,r)=>(e.split(" ").forEach(e=>{r.removeAttribute(e)}),r)),propMap={tabindex:"tabIndex",readonly:"readOnly",for:"htmlFor",class:"className",maxlength:"maxLength",cellspacing:"cellSpacing",cellpadding:"cellPadding",rowspan:"rowSpan",colspan:"colSpan",usemap:"useMap",frameborder:"frameBorder",contenteditable:"contentEditable"},prop=curryWith((e,r,t)=>{if(isElement(r)&&void 0===t&&(t=r,r=void 0),"string"==typeof e){if(void 0===r)return t[propMap[e]||e];t[propMap[e]||e]=r}else Object.entries(e).forEach(e=>{let r=_slicedToArray(e,2),n=r[0],i=r[1];t[propMap[n]||n]=i});return t},isElement),removeProp=curry((e,r)=>(e.split(" ").forEach(e=>{delete r[e=propMap[e]||e]}),r)),clone=curry(e=>e.cloneNode(!0)),detach=curry(e=>(e.parentNode&&e.parentNode.removeChild(e),e)),remove=curry(e=>e.remove()),empty=curry(e=>{for(;e.lastChild;)e.removeChild(e.lastChild);return e}),html=curryWith((e,r)=>(isString(e)||void 0!==r||(r=e,e=void 0),void 0===e?r.innerHTML:(r.innerHTML=e,r)),isElement),text=curryWith((e,r)=>(isString(e)||void 0!==r||(r=e,e=void 0),void 0===e?r.textContent:(r.textContent=e,r)),isElement),append=curry((e,r)=>(isString(e)?r.insertAdjacentHTML("beforeend",e):r.append(e),r)),appendTo=curry((e,r)=>(isString(e)&&(e=parseHTML(e)),r.append(e),e)),prepend=curry((e,r)=>(isString(e)?r.insertAdjacentHTML("afterbegin",e):r.prepend(e),r)),prependTo=curry((e,r)=>(isString(e)&&(e=parseHTML(e)),r.prepend(e),e)),before=curry((e,r)=>(isString(e)?r.insertAdjacentHTML("beforebegin",e):r.parentNode.insertBefore(e,r),r)),insertBefore=curry((e,r)=>(isString(e)&&(e=parseHTML(e)),NodeList.prototype.isPrototypeOf(e)?e.forEach(e=>{r.parentNode.insertBefore(e,r)}):r.parentNode.insertBefore(e,r),e)),after=curry((e,r)=>(isString(e)?r.insertAdjacentHTML("afterend",e):r.parentNode.insertBefore(e,r.nextElementSibling),r)),insertAfter=curry((e,r)=>(isString(e)&&(e=parseHTML(e)),NodeList.prototype.isPrototypeOf(e)?e.forEach(e=>{r.parentNode.insertBefore(e,r.nextElementSibling)}):r.parentNode.insertBefore(e,r.nextElementSibling),e)),wrap=curry((e,r)=>(isString(e)&&(e=parseHTML(e)),insertBefore(e,r),append(r,e),e)),wrapInner=curry((e,r)=>(isString(e)&&(e=parseHTML(e)),e.innerHTML=r.innerHTML,r.innerHTML="",r.append(e),r)),wrapAll=curry((e,r)=>(isString(e)&&(e=parseHTML(e)),insertBefore(e,r[0]),e.append(...r),e)),unwrap=curryWith((e,r)=>{isString(e)||void 0!==r||(r=e,e=void 0);const t=r.parentNode;return e&&!t.matches(e)||(children(t).forEach(e=>{insertBefore(e,t)}),t.remove()),r},isElement),replace=curry((e,r)=>(isString(e)&&(e=parseHTML(e)),r.parentNode.replaceChild(e,r),r.remove(),e));export{parseHTML,query,queryAll,find,findAll,has,contents,children,siblings,prev,next,prevWith,nextWith,parent,parents,parentWith,closest,offsetParent,scrollParent,indexOf,getData,setData,removeData,hasData,data,attr,removeAttr,prop,removeProp,clone,detach,remove,empty,html,text,append,appendTo,prepend,prependTo,before,insertBefore,after,insertAfter,wrap,wrapInner,wrapAll,unwrap,replace};
/*!
* @pluginjs/dom v0.7.2 (https://pluginjs.com)
* @pluginjs/dom v0.7.3 (https://pluginjs.com)
* Copyright 2018 Creation Studio Limited

@@ -4,0 +4,0 @@ * Released under the GPL-3.0 License.

/*!
* @pluginjs/dom v0.7.2 (https://pluginjs.com)
* @pluginjs/dom v0.7.3 (https://pluginjs.com)
* Copyright 2018 Creation Studio Limited

@@ -4,0 +4,0 @@ * Released under the GPL-3.0 License.

@@ -14,3 +14,3 @@ {

},
"version": "0.7.2",
"version": "0.7.3",
"category": "utils",

@@ -37,4 +37,4 @@ "main": "dist/dom.common.js",

"dependencies": {
"@pluginjs/is": "^0.7.2",
"@pluginjs/utils": "^0.7.2"
"@pluginjs/is": "^0.7.3",
"@pluginjs/utils": "^0.7.3"
},

@@ -44,3 +44,3 @@ "devDependencies": {

"@pluginjs/browserslist-config": "^1.2.2",
"@pluginjs/cli": "^0.7.2",
"@pluginjs/cli": "^0.7.3",
"babel-jest": "*",

@@ -71,3 +71,3 @@ "jest": "*",

],
"gitHead": "f18c85114d702b75d2d67e57e43b51100f161f31"
"gitHead": "304f657f71c8be62068380bd34fdc7f003082a24"
}
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