1
0
mirror of https://github.com/DataTables/DataTables.git synced 2025-02-20 18:54:15 +01:00

Dev: Trivial tidy up of _fnConvertToWidth

- Just 43 bytes saved, but tidier code and smaller size...
This commit is contained in:
Allan Jardine 2013-02-18 08:47:47 +00:00
parent 7c53a1824c
commit a67ff2fadb
2 changed files with 18 additions and 20 deletions

View File

@ -3563,25 +3563,24 @@
*/
function _fnConvertToWidth ( sWidth, nParent )
{
if ( !sWidth || sWidth === null || sWidth === '' )
if ( ! sWidth )
{
return 0;
}
if ( !nParent )
if ( ! nParent )
{
nParent = document.body;
}
var iWidth;
var nTmp = document.createElement( "div" );
nTmp.style.width = _fnStringToCss( sWidth );
var n = $('<div/>')
.css( 'width', _fnStringToCss( sWidth ) )
.appendTo( nParent );
var width = n.offsetWidth;
n.remove();
nParent.appendChild( nTmp );
iWidth = nTmp.offsetWidth;
nParent.removeChild( nTmp );
return ( iWidth );
return width;
}

View File

@ -7,25 +7,24 @@
*/
function _fnConvertToWidth ( sWidth, nParent )
{
if ( !sWidth || sWidth === null || sWidth === '' )
if ( ! sWidth )
{
return 0;
}
if ( !nParent )
if ( ! nParent )
{
nParent = document.body;
}
var iWidth;
var nTmp = document.createElement( "div" );
nTmp.style.width = _fnStringToCss( sWidth );
var n = $('<div/>')
.css( 'width', _fnStringToCss( sWidth ) )
.appendTo( nParent );
var width = n.offsetWidth;
n.remove();
nParent.appendChild( nTmp );
iWidth = nTmp.offsetWidth;
nParent.removeChild( nTmp );
return ( iWidth );
return width;
}