|
2813 | 2813 | *
|
2814 | 2814 | * ##### Notes
|
2815 | 2815 | *
|
2816 |
| - * Internet Explorer returns literal values while other browsers return |
2817 |
| - * computed values. |
| 2816 | + * Not all CSS shorthand properties are supported. You may only use the CSS |
| 2817 | + * properties described in the |
| 2818 | + * [Document Object Model (DOM) Level 2 Style Specification](http://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-ElementCSSInlineStyle). |
| 2819 | + * |
| 2820 | + * Old versions of Internet Explorer return _literal_ values; other browsers |
| 2821 | + * return _computed_ values. |
2818 | 2822 | *
|
2819 | 2823 | * Consider the following HTML snippet:
|
2820 | 2824 | *
|
|
2833 | 2837 | * // -> '1em' in Internet Explorer,
|
2834 | 2838 | * // -> '12px' elsewhere.
|
2835 | 2839 | *
|
| 2840 | + * |
2836 | 2841 | * Safari returns `null` for *any* non-inline property if the element is
|
2837 | 2842 | * hidden (has `display` set to `'none'`).
|
| 2843 | + * |
| 2844 | + * ##### Caveats |
| 2845 | + * |
| 2846 | + * Early versions of Prototype attempted to "fix" this behavior for |
| 2847 | + * certain properties. A few examples: |
| 2848 | + * |
| 2849 | + * 1. Reading and writing the CSS `opacity` property works exactly like |
| 2850 | + * calling [[Element.getOpacity]] and [[Element.setOpacity]] |
| 2851 | + * respectively. This lets us pretend that IE didn't have a |
| 2852 | + * properietary way to set opacity in versions 6-7. |
| 2853 | + * 2. Browsers disagree on how to report certain properties of hidden |
| 2854 | + * elements (i.e., `display: none`). Opera, for instance, says that a |
| 2855 | + * hidden element has a `width` of `0px`. It's an arguable point, but |
| 2856 | + * we return `null` in those cases instead (so as to agree with the |
| 2857 | + * majority behavior). **In short: if an element is hidden, |
| 2858 | + * `getStyle('width')` and `getStyle('height')` will return `null`.** |
| 2859 | + * 3. In older versions of Internet Explorer, Prototype will return a |
| 2860 | + * pixel value for `width` and `height`, even if the literal value is |
| 2861 | + * a different unit. It does this by treating `width` like `offsetWidth` |
| 2862 | + * and `height` like `offsetHeight`. This is often the incorrect |
| 2863 | + * measurement, but it's a mistake we're stuck with for |
| 2864 | + * backward-compatibility. **If you're trying to measure an element's |
| 2865 | + * dimensions, don't use `getStyle`; use [[Element.measure]] instead.** |
2838 | 2866 | *
|
2839 |
| - * Not all CSS shorthand properties are supported. You may only use the CSS |
2840 |
| - * properties described in the |
2841 |
| - * [Document Object Model (DOM) Level 2 Style Specification](http://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-ElementCSSInlineStyle). |
2842 | 2867 | **/
|
2843 | 2868 | function getStyle(element, style) {
|
2844 | 2869 | element = $(element);
|
|
0 commit comments