dom-helpers
Advanced tools
Comparing version 1.2.4 to 1.3.1
@@ -1,6 +0,6 @@ | ||
"use strict"; | ||
var hasClass = require("./hasClass"); | ||
'use strict'; | ||
var hasClass = require('./hasClass'); | ||
module.exports = function addClass(element, className) { | ||
if (element.classList) element.classList.add(className);else if (!hasClass(element)) element.className = element.className + " " + className; | ||
if (element.classList) element.classList.add(className);else if (!hasClass(element)) element.className = element.className + ' ' + className; | ||
}; |
@@ -1,4 +0,4 @@ | ||
"use strict"; | ||
'use strict'; | ||
module.exports = function hasClass(element, className) { | ||
if (element.classList) return !!className && element.classList.contains(className);else return (" " + element.className + " ").indexOf(" " + className + " ") !== -1; | ||
if (element.classList) return !!className && element.classList.contains(className);else return (' ' + element.className + ' ').indexOf(' ' + className + ' ') !== -1; | ||
}; |
@@ -1,7 +0,7 @@ | ||
"use strict"; | ||
'use strict'; | ||
module.exports = { | ||
addClass: require("./addClass"), | ||
removeClass: require("./removeClass"), | ||
hasClass: require("./hasClass") | ||
addClass: require('./addClass'), | ||
removeClass: require('./removeClass'), | ||
hasClass: require('./hasClass') | ||
}; |
@@ -1,5 +0,5 @@ | ||
"use strict"; | ||
'use strict'; | ||
module.exports = function removeClass(element, className) { | ||
if (element.classList) element.classList.remove(className);else element.className = element.className.replace(new RegExp("(^|\\s)" + className + "(?:\\s|$)", "g"), "$1").replace(/\s+/g, " ").replace(/^\s*|\s*$/g, ""); | ||
if (element.classList) element.classList.remove(className);else element.className = element.className.replace(new RegExp('(^|\\s)' + className + '(?:\\s|$)', 'g'), '$1').replace(/\s+/g, ' ').replace(/^\s*|\s*$/g, ''); | ||
}; |
@@ -1,5 +0,6 @@ | ||
"use strict"; | ||
var on = require("./on"), | ||
off = require("./off"); | ||
'use strict'; | ||
var on = require('./on'), | ||
off = require('./off'), | ||
filter = require('./filter'); | ||
module.exports = { on: on, off: off }; | ||
module.exports = { on: on, off: off, filter: filter }; |
@@ -1,4 +0,4 @@ | ||
"use strict"; | ||
var canUseDOM = require("../util/inDOM"); | ||
var off = function () {}; | ||
'use strict'; | ||
var canUseDOM = require('../util/inDOM'); | ||
var off = function off() {}; | ||
@@ -12,3 +12,3 @@ if (canUseDOM) { | ||
};else if (document.attachEvent) return function (node, eventName, handler) { | ||
return node.detachEvent("on" + eventName, handler); | ||
return node.detachEvent('on' + eventName, handler); | ||
}; | ||
@@ -15,0 +15,0 @@ })(); |
@@ -1,4 +0,4 @@ | ||
"use strict"; | ||
var canUseDOM = require("../util/inDOM"); | ||
var on = function () {}; | ||
'use strict'; | ||
var canUseDOM = require('../util/inDOM'); | ||
var on = function on() {}; | ||
@@ -11,3 +11,3 @@ if (canUseDOM) { | ||
};else if (document.attachEvent) return function (node, eventName, handler) { | ||
return node.attachEvent("on" + eventName, handler); | ||
return node.attachEvent('on' + eventName, handler); | ||
}; | ||
@@ -14,0 +14,0 @@ })(); |
14
index.js
@@ -1,10 +0,12 @@ | ||
"use strict"; | ||
var babelHelpers = require("./util/babelHelpers.js"); | ||
var style = require("./style"), | ||
events = require("./events"), | ||
query = require("./query"); | ||
'use strict'; | ||
var babelHelpers = require('./util/babelHelpers.js'); | ||
var style = require('./style'), | ||
events = require('./events'), | ||
query = require('./query'); | ||
module.exports = babelHelpers._extends({}, style, events, query, { | ||
requestAnimationFrame: require("./util/requestAnimationFrame") | ||
requestAnimationFrame: require('./util/requestAnimationFrame') | ||
}); |
{ | ||
"name": "dom-helpers", | ||
"version": "1.2.4", | ||
"version": "1.3.1", | ||
"description": "tiny modular DOM lib for ie8+ ", | ||
@@ -11,2 +11,3 @@ "author": { | ||
"license": "MIT", | ||
"main": "index.js", | ||
"keywords": [ | ||
@@ -18,57 +19,17 @@ "dom-helpers", | ||
"cross-browser", | ||
"css", | ||
"classlist", | ||
"class", | ||
"events", | ||
"style", | ||
"event", | ||
"height", | ||
"width" | ||
"width", | ||
"dom-helpers", | ||
"class", | ||
"classlist", | ||
"css" | ||
], | ||
"scripts": { | ||
"test": "karma start --single-run" | ||
}, | ||
"babel": { | ||
"experimental": true, | ||
"loose": [ | ||
"all" | ||
], | ||
"whitelist": [ | ||
"es6.modules", | ||
"es6.blockScoping", | ||
"es6.arrowFunctions", | ||
"es6.spread", | ||
"es6.properties.computed", | ||
"es6.properties.shorthand", | ||
"es6.parameters.default", | ||
"es6.parameters.rest", | ||
"es6.templateLiterals", | ||
"es7.objectRestSpread" | ||
] | ||
}, | ||
"devDependencies": { | ||
"babel": "^4.7.2", | ||
"babel-loader": "^4.2.0", | ||
"chai": "^1.10.0", | ||
"chai-as-promised": "^4.1.1", | ||
"expect.js": "^0.3.1", | ||
"get-saucelabs-browsers": "^1.0.1", | ||
"gulp": "^3.8.10", | ||
"gulp-babel-helpers": "^1.1.2", | ||
"gulp-less": "^2.0.1", | ||
"gulp-plumber": "^0.6.6", | ||
"gulp-rename": "^1.2.0", | ||
"karma": "~0.12.23", | ||
"karma-html2js-preprocessor": "^0.1.0", | ||
"karma-mocha": "~0.1.9", | ||
"karma-mocha-reporter": "^0.3.1", | ||
"karma-phantomjs-launcher": "~0.1.4", | ||
"karma-sauce-launcher": "^0.2.3", | ||
"karma-sourcemap-loader": "^0.3.4", | ||
"karma-webpack": "^1.5.0", | ||
"mocha": "~1.21.4", | ||
"phantomjs": "~1.9.10", | ||
"rimraf": "^2.2.8", | ||
"simulant": "^0.1.3", | ||
"sinon-chai": "^2.6.0" | ||
"test": "karma start --single-run", | ||
"test-watch": "karma start", | ||
"clean": "gulp clean", | ||
"build": "gulp build" | ||
} | ||
} | ||
} |
@@ -1,3 +0,3 @@ | ||
"use strict"; | ||
var canUseDOM = require("../util/inDOM"); | ||
'use strict'; | ||
var canUseDOM = require('../util/inDOM'); | ||
@@ -4,0 +4,0 @@ var contains = (function () { |
@@ -1,4 +0,6 @@ | ||
var offset = require("./offset"), | ||
getWindow = require("./isWindow"); | ||
'use strict'; | ||
var offset = require('./offset'), | ||
getWindow = require('./isWindow'); | ||
module.exports = function height(node, client) { | ||
@@ -5,0 +7,0 @@ var win = getWindow(node); |
@@ -1,17 +0,20 @@ | ||
"use strict"; | ||
'use strict'; | ||
module.exports = { | ||
height: require("./height"), | ||
matches: require('./matches'), | ||
width: require("./width"), | ||
height: require('./height'), | ||
offset: require("./offset"), | ||
width: require('./width'), | ||
contains: require("./contains"), | ||
offset: require('./offset'), | ||
scrollParent: require("./scrollParent"), | ||
contains: require('./contains'), | ||
scrollTop: require("./scrollTop") | ||
scrollParent: require('./scrollParent'), | ||
scrollTop: require('./scrollTop'), | ||
querySelectorAll: require('./querySelectorAll') | ||
}; |
@@ -1,2 +0,2 @@ | ||
"use strict"; | ||
'use strict'; | ||
@@ -3,0 +3,0 @@ module.exports = function getWindow(node) { |
@@ -1,4 +0,4 @@ | ||
"use strict"; | ||
var contains = require("./contains"), | ||
getWindow = require("./isWindow"); | ||
'use strict'; | ||
var contains = require('./contains'), | ||
getWindow = require('./isWindow'); | ||
@@ -5,0 +5,0 @@ module.exports = function offset(node) { |
@@ -1,17 +0,17 @@ | ||
"use strict"; | ||
'use strict'; | ||
var css = require("../style"), | ||
height = require("./height"); | ||
var css = require('../style'), | ||
height = require('./height'); | ||
module.exports = function scrollPrarent(node) { | ||
var position = css(node, "position"), | ||
excludeStatic = position === "absolute", | ||
var position = css(node, 'position'), | ||
excludeStatic = position === 'absolute', | ||
ownerDoc = node.ownerDocument; | ||
if (position === "fixed") return ownerDoc || document; | ||
if (position === 'fixed') return ownerDoc || document; | ||
while ((node = node.parentNode) && node.nodeType !== 9) { | ||
var isStatic = excludeStatic && css(node, "position") === "static", | ||
style = css(node, "overflow") + css(node, "overflow-y") + css(node, "overflow-x"); | ||
var isStatic = excludeStatic && css(node, 'position') === 'static', | ||
style = css(node, 'overflow') + css(node, 'overflow-y') + css(node, 'overflow-x'); | ||
@@ -18,0 +18,0 @@ if (isStatic) continue; |
@@ -1,3 +0,3 @@ | ||
"use strict"; | ||
var getWindow = require("./isWindow"); | ||
'use strict'; | ||
var getWindow = require('./isWindow'); | ||
@@ -7,5 +7,5 @@ module.exports = function scrollTop(node, val) { | ||
if (val === undefined) return win ? "pageYOffset" in win ? win.pageYOffset : win.document.documentElement.scrollTop : node.scrollTop; | ||
if (val === undefined) return win ? 'pageYOffset' in win ? win.pageYOffset : win.document.documentElement.scrollTop : node.scrollTop; | ||
if (win) win.scrollTo("pageXOffset" in win ? win.pageXOffset : win.document.documentElement.scrollLeft, val);else node.scrollTop = val; | ||
if (win) win.scrollTo('pageXOffset' in win ? win.pageXOffset : win.document.documentElement.scrollLeft, val);else node.scrollTop = val; | ||
}; |
@@ -1,4 +0,6 @@ | ||
var offset = require("./offset"), | ||
getWindow = require("./isWindow"); | ||
'use strict'; | ||
var offset = require('./offset'), | ||
getWindow = require('./isWindow'); | ||
module.exports = function width(node, client) { | ||
@@ -5,0 +7,0 @@ var win = getWindow(node); |
@@ -8,3 +8,3 @@ "use strict"; | ||
return "defaultView" in doc ? doc.defaultView.opener ? node.ownerDocument.defaultView.getComputedStyle(node, null) : window.getComputedStyle(node, null) : { //ie 8 "magic" | ||
getPropertyValue: function (prop) { | ||
getPropertyValue: function getPropertyValue(prop) { | ||
var re = /(\-([a-z]){1})/g; | ||
@@ -11,0 +11,0 @@ if (prop == "float") prop = "styleFloat"; |
@@ -1,7 +0,7 @@ | ||
"use strict"; | ||
'use strict'; | ||
var camelize = require("../util/camelizeStyle"), | ||
hyphenate = require("../util/hyphenateStyle"), | ||
_getComputedStyle = require("./getComputedStyle"), | ||
removeStyle = require("./removeStyle"); | ||
var camelize = require('../util/camelizeStyle'), | ||
hyphenate = require('../util/hyphenateStyle'), | ||
_getComputedStyle = require('./getComputedStyle'), | ||
removeStyle = require('./removeStyle'); | ||
@@ -11,6 +11,6 @@ var has = Object.prototype.hasOwnProperty; | ||
module.exports = function style(node, property, value) { | ||
var css = "", | ||
var css = '', | ||
props = property; | ||
if (typeof property === "string") { | ||
if (typeof property === 'string') { | ||
if (value === undefined) return node.style[camelize(property)] || _getComputedStyle(node).getPropertyValue(property);else (props = {})[property] = value; | ||
@@ -20,6 +20,6 @@ } | ||
for (var key in props) if (has.call(props, key)) { | ||
!props[key] && props[key] !== 0 ? removeStyle(node, hyphenate(key)) : css += hyphenate(key) + ":" + props[key] + ";"; | ||
!props[key] && props[key] !== 0 ? removeStyle(node, hyphenate(key)) : css += hyphenate(key) + ':' + props[key] + ';'; | ||
} | ||
node.style.cssText += ";" + css; | ||
node.style.cssText += ';' + css; | ||
}; |
@@ -1,5 +0,5 @@ | ||
"use strict"; | ||
'use strict'; | ||
module.exports = function removeStyle(node, key) { | ||
return "removeProperty" in node.style ? node.style.removeProperty(key) : node.style.removeAttribute(key); | ||
return 'removeProperty' in node.style ? node.style.removeProperty(key) : node.style.removeAttribute(key); | ||
}; |
@@ -1,4 +0,6 @@ | ||
var transition = require("./properties"), | ||
style = require("../style"); | ||
'use strict'; | ||
var transition = require('./properties'), | ||
style = require('../style'); | ||
module.exports = function onEnd(node, handler, duration) { | ||
@@ -33,5 +35,5 @@ var fakeEvent = { | ||
var str = style(node, transition.duration), | ||
mult = str.indexOf("ms") === -1 ? 1000 : 1; | ||
mult = str.indexOf('ms') === -1 ? 1000 : 1; | ||
return parseFloat(str) * mult; | ||
} |
@@ -1,6 +0,6 @@ | ||
"use strict"; | ||
'use strict'; | ||
module.exports = { | ||
end: require("./end"), | ||
properties: require("./properties") | ||
end: require('./end'), | ||
properties: require('./properties') | ||
}; |
@@ -1,6 +0,6 @@ | ||
"use strict"; | ||
var canUseDOM = require("../util/inDOM"); | ||
'use strict'; | ||
var canUseDOM = require('../util/inDOM'); | ||
var has = Object.prototype.hasOwnProperty, | ||
transform = "transform", | ||
transform = 'transform', | ||
transition = {}, | ||
@@ -17,6 +17,6 @@ transitionTiming, | ||
transitionProperty = transition.prefix + "transition-property"; | ||
transitionDuration = transition.prefix + "transition-duration"; | ||
transitionDelay = transition.prefix + "transition-delay"; | ||
transitionTiming = transition.prefix + "transition-timing-function"; | ||
transitionProperty = transition.prefix + 'transition-property'; | ||
transitionDuration = transition.prefix + 'transition-duration'; | ||
transitionDelay = transition.prefix + 'transition-delay'; | ||
transitionTiming = transition.prefix + 'transition-timing-function'; | ||
} | ||
@@ -35,15 +35,15 @@ | ||
var endEvent, | ||
prefix = "", | ||
prefix = '', | ||
transitions = { | ||
O: "otransitionend", | ||
Moz: "transitionend", | ||
Webkit: "webkitTransitionEnd", | ||
ms: "MSTransitionEnd" | ||
O: 'otransitionend', | ||
Moz: 'transitionend', | ||
Webkit: 'webkitTransitionEnd', | ||
ms: 'MSTransitionEnd' | ||
}; | ||
var element = document.createElement("div"); | ||
var element = document.createElement('div'); | ||
for (var vendor in transitions) if (has.call(transitions, vendor)) { | ||
if (element.style[vendor + "TransitionProperty"] !== undefined) { | ||
prefix = "-" + vendor.toLowerCase() + "-"; | ||
if (element.style[vendor + 'TransitionProperty'] !== undefined) { | ||
prefix = '-' + vendor.toLowerCase() + '-'; | ||
endEvent = transitions[vendor]; | ||
@@ -54,5 +54,5 @@ break; | ||
if (!endEvent && element.style.transitionProperty !== undefined) endEvent = "transitionend"; | ||
if (!endEvent && element.style.transitionProperty !== undefined) endEvent = 'transitionend'; | ||
return { end: endEvent, prefix: prefix }; | ||
} |
@@ -0,1 +1,3 @@ | ||
"use strict"; | ||
var rHyphen = /-(.)/g; | ||
@@ -2,0 +4,0 @@ |
@@ -7,8 +7,8 @@ /** | ||
"use strict"; | ||
var camelize = require("./camelize"); | ||
'use strict'; | ||
var camelize = require('./camelize'); | ||
var msPattern = /^-ms-/; | ||
module.exports = function camelizeStyleName(string) { | ||
return camelize(string.replace(msPattern, "ms-")); | ||
return camelize(string.replace(msPattern, 'ms-')); | ||
}; |
@@ -0,1 +1,2 @@ | ||
'use strict'; | ||
@@ -5,3 +6,3 @@ var rUpper = /([A-Z])/g; | ||
module.exports = function hyphenate(string) { | ||
return string.replace(rUpper, "-$1").toLowerCase(); | ||
return string.replace(rUpper, '-$1').toLowerCase(); | ||
}; |
@@ -1,2 +0,2 @@ | ||
"use strict"; | ||
module.exports = !!(typeof window !== "undefined" && window.document && window.document.createElement); | ||
'use strict'; | ||
module.exports = !!(typeof window !== 'undefined' && window.document && window.document.createElement); |
@@ -1,27 +0,25 @@ | ||
"use strict"; | ||
'use strict'; | ||
var canUseDOM = require("./inDOM"); | ||
var canUseDOM = require('./inDOM'); | ||
var cancel = "clearTimeout", | ||
var vendors = ['', 'webkit', 'moz', 'o', 'ms'], | ||
cancel = 'clearTimeout', | ||
raf = fallback, | ||
compatRaf; | ||
var keys = ["cancelAnimationFrame", "webkitCancelAnimationFrame", "mozCancelAnimationFrame", "oCancelAnimationFrame", "msCancelAnimationFrame"]; | ||
compatRaf = function (cb) { | ||
return raf(cb); | ||
var getKey = function getKey(vendor, k) { | ||
return vendor + (!vendor ? k : k[0].toUpperCase() + k.substr(1)) + 'AnimationFrame'; | ||
}; | ||
compatRaf.cancel = function (id) { | ||
return window[cancel](id); | ||
}; | ||
module.exports = compatRaf; | ||
if (canUseDOM) { | ||
raf = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || fallback; | ||
vendors.some(function (vendor) { | ||
var rafKey = getKey(vendor, 'request'); | ||
for (var i = 0; i < keys.length; i++) if (keys[i] in window) { | ||
cancel = keys[i]; | ||
break; | ||
} | ||
if (rafKey in window) { | ||
cancel = getKey(vendor, 'cancel'); | ||
return raf = function (cb) { | ||
return window[rafKey](cb); | ||
}; | ||
} | ||
}); | ||
} | ||
@@ -36,4 +34,14 @@ | ||
req = setTimeout(fn, ms); | ||
prev = curr; | ||
return req; | ||
} | ||
} | ||
compatRaf = function (cb) { | ||
return raf(cb); | ||
}; | ||
compatRaf.cancel = function (id) { | ||
return window[cancel](id); | ||
}; | ||
module.exports = compatRaf; |
@@ -1,15 +0,17 @@ | ||
var canUseDOM = require("./inDOM"); | ||
var style = require("../style"); | ||
'use strict'; | ||
var canUseDOM = require('./inDOM'); | ||
var style = require('../style'); | ||
var size; | ||
if (canUseDOM) { | ||
var scrollDiv = document.createElement("div"); | ||
var scrollDiv = document.createElement('div'); | ||
style(scrollDiv, { | ||
position: "absolute", | ||
top: "-9999px", | ||
width: "50px", | ||
height: "50px", | ||
overflow: "scroll" | ||
position: 'absolute', | ||
top: '-9999px', | ||
width: '50px', | ||
height: '50px', | ||
overflow: 'scroll' | ||
}); | ||
@@ -16,0 +18,0 @@ |
@@ -1,8 +0,8 @@ | ||
"use strict"; | ||
var getOffset = require("../query/offset"), | ||
height = require("../query/height"), | ||
getScrollParent = require("../query/scrollParent"), | ||
scrollTop = require("../query/scrollTop"), | ||
raf = require("./requestAnimationFrame"), | ||
getWindow = require("./isWindow"); | ||
'use strict'; | ||
var getOffset = require('../query/offset'), | ||
height = require('../query/height'), | ||
getScrollParent = require('../query/scrollParent'), | ||
scrollTop = require('../query/scrollTop'), | ||
raf = require('./requestAnimationFrame'), | ||
getWindow = require('./isWindow'); | ||
@@ -9,0 +9,0 @@ module.exports = function scrollTo(selected, scrollParent) { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
0
1
17112
35
431
1
0
1