3 Copyright 2012 Yahoo! Inc. All rights reserved.
4 Licensed under the BSD License.
5 http://yuilibrary.com/license/
7 YUI.add('dom-size', function(Y) {
11 * Sets the width of the element to the given size, regardless
12 * of box model, border, padding, etc.
14 * @param {HTMLElement} element The DOM element.
15 * @param {String|Int} size The pixel height to size to
18 setWidth: function(node, size) {
19 Y.DOM._setSize(node, 'width', size);
23 * Sets the height of the element to the given size, regardless
24 * of box model, border, padding, etc.
26 * @param {HTMLElement} element The DOM element.
27 * @param {String|Int} size The pixel height to size to
30 setHeight: function(node, size) {
31 Y.DOM._setSize(node, 'height', size);
34 _setSize: function(node, prop, val) {
35 val = (val > 0) ? val : 0;
38 node.style[prop] = val + 'px';
39 size = (prop === 'height') ? node.offsetHeight : node.offsetWidth;
42 val = val - (size - val);
48 node.style[prop] = val + 'px';
54 }, '3.5.0' ,{requires:['dom-core']});