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

dom-align

Package Overview
Dependencies
Maintainers
1
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dom-align - npm Package Compare versions

Comparing version 1.0.5 to 1.0.6

150

lib/utils.js

@@ -0,3 +1,28 @@

'use strict';
var RE_NUM = /[\-+]?(?:\d*\.|)\d+(?:[eE][\-+]?\d+|)/.source;
var getComputedStyleX;
if (typeof window !== 'undefined') {
getComputedStyleX = window.getComputedStyle ? _getComputedStyle : _getComputedStyleIE;
}
function css(el, name, value) {
if (typeof name === 'object') {
for (var i in name) {
css(el, i, name[i]);
}
return undefined;
}
if (typeof value !== 'undefined') {
if (typeof value === 'number') {
value = value + 'px';
}
el.style[name] = value;
return undefined;
} else {
return getComputedStyleX(el, name);
}
}
function getClientPosition(elem) {

@@ -41,3 +66,3 @@ var box, x, y;

return {left: x, top: y};
return { left: x, top: y };
}

@@ -81,3 +106,3 @@

// https://github.com/kissyteam/kissy/issues/61
if ((computedStyle = (computedStyle || d.defaultView.getComputedStyle(elem, null)))) {
if (computedStyle = computedStyle || d.defaultView.getComputedStyle(elem, null)) {
val = computedStyle.getPropertyValue(name) || computedStyle[name];

@@ -91,6 +116,6 @@ }

var RE_POS = /^(top|right|bottom|left)$/,
CURRENT_STYLE = 'currentStyle',
RUNTIME_STYLE = 'runtimeStyle',
LEFT = 'left',
PX = 'px';
CURRENT_STYLE = 'currentStyle',
RUNTIME_STYLE = 'runtimeStyle',
LEFT = 'left',
PX = 'px';

@@ -115,4 +140,4 @@ function _getComputedStyleIE(elem, name) {

var style = elem.style,
left = style[LEFT],
rsLeft = elem[RUNTIME_STYLE][LEFT];
left = style[LEFT],
rsLeft = elem[RUNTIME_STYLE][LEFT];

@@ -123,3 +148,3 @@ // prevent flashing of content

// Put in the new values to get a computed value out
style[LEFT] = name === 'fontSize' ? '1em' : (ret || 0);
style[LEFT] = name === 'fontSize' ? '1em' : ret || 0;
ret = style.pixelLeft + PX;

@@ -135,7 +160,2 @@

var getComputedStyleX;
if (typeof window !== 'undefined') {
getComputedStyleX = window.getComputedStyle ? _getComputedStyle : _getComputedStyleIE;
}
// 设置 elem 相对 elem.ownerDocument 的坐标

@@ -149,4 +169,5 @@ function setOffset(elem, offset) {

var old = getOffset(elem),
ret = {},
current, key;
ret = {},
current,
key;

@@ -171,11 +192,11 @@ for (key in offset) {

var BOX_MODELS = ['margin', 'border', 'padding'],
CONTENT_INDEX = -1,
PADDING_INDEX = 2,
BORDER_INDEX = 1,
MARGIN_INDEX = 0;
CONTENT_INDEX = -1,
PADDING_INDEX = 2,
BORDER_INDEX = 1,
MARGIN_INDEX = 0;
function swap(elem, options, callback) {
var old = {},
style = elem.style,
name;
style = elem.style,
name;

@@ -197,3 +218,6 @@ // Remember the old values, and insert the new ones

function getPBMWidth(elem, props, which) {
var value = 0, prop, j, i;
var value = 0,
prop,
j,
i;
for (j = 0; j < props.length; j++) {

@@ -222,3 +246,3 @@ prop = props[j];

// must use == for ie8
/*jshint eqeqeq:false*/
/*eslint eqeqeq:0*/
return obj != null && obj == obj.window;

@@ -233,8 +257,7 @@ }

return Math.max(
//firefox chrome documentElement.scrollHeight< body.scrollHeight
//ie standard mode : documentElement.scrollHeight> body.scrollHeight
d.documentElement['scroll' + name],
//quirks : documentElement.scrollHeight 最大等于可视窗口多一点?
d.body['scroll' + name],
domUtils['viewport' + name](d));
//firefox chrome documentElement.scrollHeight< body.scrollHeight
//ie standard mode : documentElement.scrollHeight> body.scrollHeight
d.documentElement['scroll' + name],
//quirks : documentElement.scrollHeight 最大等于可视窗口多一点?
d.body['scroll' + name], domUtils['viewport' + name](d));
};

@@ -245,10 +268,9 @@

var prop = 'client' + name,
doc = win.document,
body = doc.body,
documentElement = doc.documentElement,
documentElementProp = documentElement[prop];
doc = win.document,
body = doc.body,
documentElement = doc.documentElement,
documentElementProp = documentElement[prop];
// 标准模式取 documentElement
// backcompat 取 body
return doc.compatMode === 'CSS1Compat' && documentElementProp ||
body && body[prop] || documentElementProp;
return doc.compatMode === 'CSS1Compat' && documentElementProp || body && body[prop] || documentElementProp;
};

@@ -272,3 +294,3 @@ });

var which = name === 'width' ? ['Left', 'Right'] : ['Top', 'Bottom'],
borderBoxValue = name === 'width' ? elem.offsetWidth : elem.offsetHeight;
borderBoxValue = name === 'width' ? elem.offsetWidth : elem.offsetHeight;
var computedStyle = getComputedStyleX(elem);

@@ -281,3 +303,3 @@ var isBorderBox = isBorderBoxFn(elem, computedStyle);

cssBoxValue = getComputedStyleX(elem, name);
if (cssBoxValue == null || (Number(cssBoxValue)) < 0) {
if (cssBoxValue == null || Number(cssBoxValue) < 0) {
cssBoxValue = elem.style[name] || 0;

@@ -295,4 +317,3 @@ }

if (borderBoxValueOrIsBorderBox) {
return val - getPBMWidth(elem, ['border', 'padding'],
which, computedStyle);
return val - getPBMWidth(elem, ['border', 'padding'], which, computedStyle);
} else {

@@ -302,17 +323,14 @@ return cssBoxValue;

} else if (borderBoxValueOrIsBorderBox) {
return val + (extra === BORDER_INDEX ? 0 :
(extra === PADDING_INDEX ?
-getPBMWidth(elem, ['border'], which, computedStyle) :
getPBMWidth(elem, ['margin'], which, computedStyle)));
return val + (extra === BORDER_INDEX ? 0 : extra === PADDING_INDEX ? -getPBMWidth(elem, ['border'], which, computedStyle) : getPBMWidth(elem, ['margin'], which, computedStyle));
} else {
return cssBoxValue + getPBMWidth(elem, BOX_MODELS.slice(extra),
which, computedStyle);
return cssBoxValue + getPBMWidth(elem, BOX_MODELS.slice(extra), which, computedStyle);
}
}
var cssShow = {position: 'absolute', visibility: 'hidden', display: 'block'};
var cssShow = { position: 'absolute', visibility: 'hidden', display: 'block' };
// fix #119 : https://github.com/kissyteam/kissy/issues/119
function getWHIgnoreDisplay(elem) {
var val, args = arguments;
var val,
args = arguments;
// in case elem is window

@@ -347,3 +365,3 @@ // elem.offsetWidth === undefined

}
return;
return undefined;
}

@@ -354,19 +372,2 @@ return elem && getWHIgnoreDisplay(elem, name, CONTENT_INDEX);

function css(el, name, value) {
if (typeof name === 'object') {
for (var i in name) {
css(el, i, name[i]);
}
return;
}
if (typeof value !== 'undefined') {
if (typeof value === 'number') {
value = value + 'px';
}
el.style[name] = value;
} else {
return getComputedStyleX(el, name);
}
}
function mix(to, from) {

@@ -380,3 +381,3 @@ for (var i in from) {

var utils = module.exports = {
getWindow: function (node) {
getWindow: function getWindow(node) {
if (node && node.document && node.setTimeout) {

@@ -388,3 +389,3 @@ return node;

},
offset: function (el, value) {
offset: function offset(el, value) {
if (typeof value !== 'undefined') {

@@ -399,5 +400,6 @@ setOffset(el, value);

css: css,
clone: function (obj) {
clone: function clone(obj) {
var i;
var ret = {};
for (var i in obj) {
for (i in obj) {
ret[i] = obj[i];

@@ -414,9 +416,9 @@ }

mix: mix,
getWindowScrollLeft: function (w) {
getWindowScrollLeft: function getWindowScrollLeft(w) {
return getScrollLeft(w);
},
getWindowScrollTop: function (w) {
getWindowScrollTop: function getWindowScrollTop(w) {
return getScrollTop(w);
},
merge: function () {
merge: function merge() {
var ret = {};

@@ -432,2 +434,2 @@ for (var i = 0; i < arguments.length; i++) {

mix(utils, domUtils);
mix(utils, domUtils);
{
"name": "dom-align",
"version": "1.0.5",
"version": "1.0.6",
"description": "Align DOM Node Flexibly ",

@@ -10,3 +10,4 @@ "keywords": [

"homepage": "http://github.com/yiminghe/dom-align",
"author": "",
"main":"lib/index",
"author": "yiminghe@gmail.com",
"repository": {

@@ -26,12 +27,11 @@ "type": "git",

"build": "rc-tools run build",
"precommit": "rc-tools run precommit",
"less": "rc-tools run less",
"gh-pages": "rc-tools run gh-pages",
"history": "rc-tools run history",
"start": "node --harmony node_modules/.bin/rc-server",
"publish": "spm publish && rc-tools run tag",
"publish": "rc-tools run tag && spm publish",
"lint": "rc-tools run lint",
"test": "",
"saucelabs": "rc-tools run saucelabs",
"browser-test": "rc-tools run browser-test",
"browser-test-cover": "rc-tools run browser-test-cover"
"saucelabs": "node --harmony node_modules/.bin/rc-tools run saucelabs",
"browser-test": "node --harmony node_modules/.bin/rc-tools run browser-test",
"browser-test-cover": "node --harmony node_modules/.bin/rc-tools run browser-test-cover"
},

@@ -42,10 +42,9 @@ "devDependencies": {

"precommit-hook": "^1.0.7",
"rc-server": "~2.1.3",
"rc-tools": "2.x",
"rc-server": "3.x",
"rc-tools": "3.x",
"react": "^0.13.0"
},
"precommit": [
"lint",
"less"
"precommit"
]
}
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