UNPKG

dom-tools

Version:

A tiny collection of DOM helpers for IE8+.

18 lines (15 loc) 503 B
var _getComputedStyle = require('./getComputedStyle'); // IE8+ // // "$.outerWidth()" http://youmightnotneedjquery.com/#outer_width // "$.outerWidth(true)" http://youmightnotneedjquery.com/#outer_width_with_margin function outerWidth(/* Element */ el, withMargin) { var width = el.offsetWidth; if (withMargin) { var style = _getComputedStyle(el); width += parseInt(style.marginLeft) + parseInt(style.marginRight); return width; } return width; } module.exports = outerWidth;