dom-style-debug.js revision f0a0f2d277e1e155c4c94f8f2102112ead6179c5
4812N/A * Add style management functionality to DOM. * Sets a style property for a given element. * @param {HTMLElement} An HTMLElement to apply the style to. * @param {String} att The style property to set. * @param {String|Number} val The value. val =
'';
// normalize for unsetting * Returns the current style value for the given property. * @param {HTMLElement} An HTMLElement to get the style from. * @param {String} att The style property to get. if (
val ===
'') {
// TODO: is empty string sufficient? * Sets multiple style properties. * @param {HTMLElement} node An HTMLElement to apply the styles to. * @param {Object} hash An object literal of property:value pairs. * Returns the computed style for the given node. * @method getComputedStyle * @param {HTMLElement} An HTMLElement to get the style from. * @param {String} att The style property to get. * @return {String} The computed value of the style property. // normalize reserved word float alternatives ("cssFloat" or "styleFloat") // fix opera computedStyle default color unit (convert to rgb) // safari converts transparent to rgba(), others use "transparent" if (
val ===
'rgba(0, 0, 0, 0)') {
re_RGB: /^
rgb\(([
0-
9]+)\s*,\s*([
0-
9]+)\s*,\s*([
0-
9]+)\)$/i,
re_hex: /^#?([
0-
9A-F]{
2})([
0-
9A-F]{
2})([
0-
9A-F]{
2})$/i,
// TODO: unit-less lineHeight (e.g. 1.22) width: [
'Left',
'Right'],
offset =
'offset' +
capped,
// "offsetWidth", "offsetTop", etc. pixel =
'pixel' +
capped,
// "pixelWidth", "pixelTop", etc. // IE pixelWidth incorrect for percent // manually compute by subtracting padding and border from offset size // NOTE: clientWidth/Height (size minus border) is 0 when current === AUTO so offsetHeight is used // reverting to auto from auto causes position stacking issues (old impl) }
else {
// use style.pixelWidth, etc. to convert to pixels // need to map style.width to currentStyle (no currentStyle.pixelWidth) Y.
log(
'borderWidth computing not implemented',
'warn',
'dom-ie-style');
// use pixelRight to convert to px //fontSize: getPixelFont, // use alpha filter for IE opacity try {
// will error if no DXImageTransform try {
// make sure its in the document Y.
log(
'getStyle: IE opacity filter not found; returning 1',
'warn',
'dom-style');
if (
val ===
'') {
// normalize inline style behavior if (
typeof style[
FILTER] ==
'string') {
// in case not appended Y.
log(
'document.documentElement.filters error (activeX disabled)',
'warn',
'dom-style');
}
catch(e) {
// IE throws error on invalid style set; trap common cases Y.
log(
'invalid style value for height: ' +
val,
'warn',
'dom-style');
Y.
log(
'invalid style value for width: ' +
val,
'warn',
'dom-style');
// TODO: top, right, bottom, left * Sets the width of the element to the given size, regardless * of box model, border, padding, etc. * @param {HTMLElement} element The DOM element. * @param {String|Int} size The pixel height to size to * Sets the height of the element to the given size, regardless * of box model, border, padding, etc. * @param {HTMLElement} element The DOM element. * @param {String|Int} size The pixel height to size to val =
0;
// no negative sizes },
'@VERSION@' ,{
requires:[
'dom-base']});