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

get-size

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

get-size - npm Package Compare versions

Comparing version 1.1.8 to 1.2.0

test/iframe.html

2

bower.json
{
"name": "get-size",
"version": "1.1.8",
"version": "1.2.0",
"main": "get-size.js",

@@ -5,0 +5,0 @@ "description": "measures element size",

@@ -5,3 +5,3 @@ {

"description": "measures element size",
"version": "1.1.8",
"version": "1.2.0",
"dependencies": {

@@ -8,0 +8,0 @@ "desandro/get-style-property": "*"

/*!
* getSize v1.1.8
* getSize v1.2.0
* measure size of elements

@@ -16,11 +16,2 @@ * MIT license

var getComputedStyle = window.getComputedStyle;
var getStyle = getComputedStyle ?
function( elem ) {
return getComputedStyle( elem, null );
} :
function( elem ) {
return elem.currentStyle;
};
// get a number from a string, not a percentage

@@ -34,2 +25,7 @@ function getStyleSize( value ) {

var logError = typeof console === 'undefined' ? noop :
function( message ) {
console.error( message );
};
// -------------------------- measurements -------------------------- //

@@ -72,35 +68,72 @@

// -------------------------- box sizing -------------------------- //
// -------------------------- setup -------------------------- //
var boxSizingProp = getStyleProperty('boxSizing');
var isBoxSizeOuter;
var isSetup = false;
var getStyle, boxSizingProp, isBoxSizeOuter;
/**
* WebKit measures the outer-width on style.width on border-box elems
* IE & Firefox measures the inner-width
* setup vars and functions
* do it on initial getSize(), rather than on script load
* For Firefox bug https://bugzilla.mozilla.org/show_bug.cgi?id=548397
*/
( function() {
if ( !boxSizingProp ) {
function setup() {
// setup once
if ( isSetup ) {
return;
}
isSetup = true;
var div = document.createElement('div');
div.style.width = '200px';
div.style.padding = '1px 2px 3px 4px';
div.style.borderStyle = 'solid';
div.style.borderWidth = '1px 2px 3px 4px';
div.style[ boxSizingProp ] = 'border-box';
var getComputedStyle = window.getComputedStyle;
getStyle = ( function() {
var getStyleFn = getComputedStyle ?
function( elem ) {
return getComputedStyle( elem, null );
} :
function( elem ) {
return elem.currentStyle;
};
var body = document.body || document.documentElement;
body.appendChild( div );
var style = getStyle( div );
return function getStyle( elem ) {
var style = getStyleFn( elem );
if ( !style ) {
logError( 'Style returned ' + style +
'. Are you running this code in a hidden iframe on Firefox? ' +
'See http://bit.ly/getsizeiframe' );
}
return style;
}
})();
isBoxSizeOuter = getStyleSize( style.width ) === 200;
body.removeChild( div );
})();
// -------------------------- box sizing -------------------------- //
boxSizingProp = getStyleProperty('boxSizing');
/**
* WebKit measures the outer-width on style.width on border-box elems
* IE & Firefox measures the inner-width
*/
if ( boxSizingProp ) {
var div = document.createElement('div');
div.style.width = '200px';
div.style.padding = '1px 2px 3px 4px';
div.style.borderStyle = 'solid';
div.style.borderWidth = '1px 2px 3px 4px';
div.style[ boxSizingProp ] = 'border-box';
var body = document.body || document.documentElement;
body.appendChild( div );
var style = getStyle( div );
isBoxSizeOuter = getStyleSize( style.width ) === 200;
body.removeChild( div );
}
}
// -------------------------- getSize -------------------------- //
function getSize( elem ) {
setup();
// use querySeletor if elem is string

@@ -107,0 +140,0 @@ if ( typeof elem === 'string' ) {

{
"name": "get-size",
"version": "1.1.8",
"version": "1.2.0",
"description": "measures element size",

@@ -5,0 +5,0 @@ "main": "get-size.js",

@@ -19,6 +19,18 @@ # getSize

Install with [Bower](http://bower.io) :bird:: `bower install get-size`
Install with [Bower](http://bower.io): `bower install get-size`
Install with npm: `npm install get-size`
## Firefox hidden iframe bug
[Firefox has an old bug](https://bugzilla.mozilla.org/show_bug.cgi?id=548397) that occurs within iframes that are hidden with `display: none`. To resolve this, you can use alternate CSS to hide the iframe off-screen, with out `display: none`.
``` css
.hide-iframe {
visibility: hidden;
position: absolute;
left: -999em;
}
```
## Fractional values in IE8

@@ -25,0 +37,0 @@

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