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

domassist

Package Overview
Dependencies
Maintainers
8
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

domassist - npm Package Compare versions

Comparing version 1.11.1 to 1.12.0

index.html

88

dist/domassist.js

@@ -19,2 +19,3 @@ var Domassist = (function (exports) {

}
return [];

@@ -29,3 +30,5 @@ }

}
var els = find(selector);
if (els.length) {

@@ -61,4 +64,5 @@ var clsArray = [].concat(cls);

window._domassistevents['_' + event] = data;
window._domassistevents["_".concat(event)] = data;
var el = find(selector);
if (el.length) {

@@ -74,5 +78,3 @@ el.forEach(function (item) {

var match = false;
var prefixes = ['matches', 'matchesSelector', 'webkitMatchesSelector', 'mozMatchesSelector', 'msMatchesSelector', 'oMatchesSelector'];
prefixes.forEach(function (prefix) {

@@ -89,7 +91,20 @@ if (proto.hasOwnProperty(prefix)) {

function closest(el, selector) {
if (matches(el, selector)) {
return el;
}
var parent = el.tagName.toLowerCase() === 'svg' ? el.parentNode : el.parentElement;
while (parent.parentElement && !matches(parent, selector)) {
parent = parent.parentElement;
}
return matches(parent, selector) ? parent : null;
}
function delegate(el, event, selector, cb) {
var capture = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
on(el, event, function (e) {
if (e.target && matches(e.target, selector)) {
if (e.target && closest(e.target, selector)) {
return cb(e);

@@ -110,8 +125,7 @@ }

var NativeCustomEvent = window.CustomEvent;
//
var NativeCustomEvent = window.CustomEvent; //
// Check for the usage of native support for CustomEvents which is lacking
// completely on IE.
//
function canIuseNativeCustom() {

@@ -128,5 +142,5 @@ try {

}
}
} // Lousy polyfill for the Custom Event constructor for IE.
// Lousy polyfill for the Custom Event constructor for IE.
var IECustomEvent = function CustomEvent(type, params) {

@@ -166,3 +180,2 @@ var e = document.createEvent('CustomEvent');

});
return els;

@@ -174,5 +187,7 @@ }

var el = findOne(selector);
if (!el) {
return false;
}
return el.classList.contains(cls);

@@ -187,3 +202,5 @@ }

}
var els = find(selector);
if (els.length) {

@@ -212,2 +229,3 @@ els.forEach(function (el) {

}
if (!window._domassistevents) {

@@ -217,3 +235,3 @@ window._domassistevents = {};

var data = window._domassistevents['_' + event];
var data = window._domassistevents["_".concat(event)];

@@ -223,3 +241,5 @@ if (!data) {

}
var el = find(selector);
if (el.length) {

@@ -234,3 +254,2 @@ el.forEach(function (item) {

var capture = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
on(el, event, function (e) {

@@ -243,3 +262,2 @@ off(el, event);

var transform = null;
function prefixedTransform() {

@@ -257,3 +275,4 @@ if (transform) {

for (var i = 0, len = vendors.length; i < len && !property; i++) {
var tProperty = vendors[i] + 'Transform';
var tProperty = "".concat(vendors[i], "Transform");
if (typeof testEl.style[tProperty] !== 'undefined') {

@@ -280,2 +299,3 @@ property = tProperty;

var els = find(selector);
if (els.length) {

@@ -292,3 +312,3 @@ var clsArray = [].concat(cls);

var SCROLLABLE_CONTAINER = void 0;
var SCROLLABLE_CONTAINER;

@@ -301,4 +321,3 @@ function getScrollableContainer() {

var documentElement = window.document.documentElement;
var scrollableContainer = void 0;
var scrollableContainer;
documentElement.scrollTop = 1;

@@ -314,3 +333,2 @@

SCROLLABLE_CONTAINER = scrollableContainer;
return scrollableContainer;

@@ -327,3 +345,5 @@ }

}
var els = find(selector);
if (els.length) {

@@ -344,16 +364,10 @@ els.forEach(function (el) {

function closest(el, selector) {
var parent = el.tagName.toLowerCase() === 'svg' ? el.parentNode : el.parentElement;
while (parent.parentElement && !matches(parent, selector)) {
parent = parent.parentElement;
}
return matches(parent, selector) ? parent : null;
}
var setupReady = function setupReady(callbacks) {
return function (callback) {
callbacks.push(callback);
function execute() {
while (callbacks.length) {
var fn = callbacks.shift();
if (typeof fn === 'function') {

@@ -364,2 +378,3 @@ fn();

}
function loaded() {

@@ -375,6 +390,6 @@ document.removeEventListener('DOMContentLoaded', loaded);

}, 0);
document.addEventListener('DOMContentLoaded', loaded);
};
};
var ready = setupReady([]);

@@ -388,3 +403,5 @@

}
var els = find(selector);
if (els.length) {

@@ -405,3 +422,5 @@ els.forEach(function (el) {

}
var els = find(selector);
if (els.length) {

@@ -418,2 +437,3 @@ els.forEach(function (item) {

}
return els;

@@ -428,5 +448,8 @@ }

}
var el = find(selector);
if (el.length) {
var length = el.length;
for (var i = 0; i < length; i += 1) {

@@ -439,3 +462,2 @@ el[i].innerHTML = value;

/* global DocumentTouch */
function isTouch() {

@@ -457,2 +479,3 @@ return 'ontouchstart' in window || window.DocumentTouch && document instanceof DocumentTouch;

}
var modules = {

@@ -466,2 +489,3 @@ addClass: addClass,

var els = find(selector);
if (els.length) {

@@ -474,2 +498,3 @@ els.forEach(function (el) {

}
modules[param](el, params[param]);

@@ -488,3 +513,5 @@ }

}
var els = find(selector);
if (els.length) {

@@ -505,8 +532,11 @@ els.forEach(function (el) {

}
if (Array.isArray(value)) {
return value;
}
if (value instanceof Node) {
return [value];
}
return [].slice.call(value);

@@ -513,0 +543,0 @@ }

import matches from './matches';
function closest(el, selector) {
if (matches(el, selector)) {
return el;
}
let parent = el.tagName.toLowerCase() === 'svg' ? el.parentNode : el.parentElement;

@@ -5,0 +8,0 @@ while (parent.parentElement && !matches(parent, selector)) {

import on from './on';
import matches from './matches';
import closest from './closest';
function delegate(el, event, selector, cb, capture = false) {
on(el, event, e => {
if (e.target && matches(e.target, selector)) {
if (e.target && closest(e.target, selector)) {
return cb(e);

@@ -8,0 +8,0 @@ }

{
"name": "domassist",
"version": "1.11.1",
"version": "1.12.0",
"description": "Various dom helpers",

@@ -34,5 +34,5 @@ "main": "dist/domassist.js",

"phantomjs-prebuilt": "^2.1.16",
"scriptkit": "0.4.0",
"scriptkit": "^1.0.0",
"static-server": "^2.2.1",
"tap-spec": "^4.1.1",
"tap-spec": "^5.0.0",
"tape-rollup": "4.6.4",

@@ -39,0 +39,0 @@ "tape-run": "^2.1.5"

@@ -17,2 +17,3 @@ /* eslint no-console: 0 */

import './append.test';
import './closest.test';

@@ -77,45 +78,2 @@ const page = window.phantom.page;

test('closest', assert => {
const el = domassist.findOne('#domassist');
const levels = 4;
// clean up test dom
while (el.firstChild) {
el.removeChild(el.firstChild);
}
function addNode(num) {
const node = document.createElement('div');
node.innerText = num;
node.classList.add(`level-${num}`);
const children = el.children;
if (children.length) {
const child = domassist.findOne(`.level-${num - 1}`);
child.appendChild(node);
} else {
el.appendChild(node);
}
}
for (let i = 0; i < levels; i += 1) {
addNode(i + 1);
}
const startEl = domassist.findOne(`.level-${levels}`);
let count = levels - 1;
while (count) {
assert.ok(domassist.closest(startEl, `.level-${count}`), `Should find element with class of level-${count}`);
--count;
}
assert.end();
});
test('closest of an SVG element', assert => {
const node = document.createElement('div');
node.className = 'svg-wrapper';
const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
node.appendChild(svg);
const closest = domassist.closest(svg, '.svg-wrapper');
assert.equal(closest, node, 'Found closest');
assert.end();
});
test('Events - delegate', assert => {

@@ -122,0 +80,0 @@ const el = domassist.findOne('#domassist');

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