The relationships among XULElement's attributes, properties, and its style's attributes and properties make me confused.

For example:
<vbox id="vbox1" height="20" style="max-height: 40px"/>

In JavaScript Debugger:
var vbox1 = document.getElementById("vbox1");
var vbox1style = document.defaultView.getComputedStyle(vbox1, "");

vbox1.height; /* result is 20 */
vbox1.maxHeight; /* result is "" */ <== NOTE A
vbox1style.maxHeight; /* result is "30px" */
vbox1style.height; /* result is "20px" */
vbox1.maxHeight = 50;
vbox1.style.height; /* exception: NS_ERROR_NOT_IMPLEMENTED [nsIDOMXULElement.style] */ <== NOTE B
vbox1.height = 100;
vbox1.height; /* result is 100 */ <== NOTE C
vbox1style.height; /* result is "50px" */ <== NOTE D
vbox1style.maxHeight; /* result is "30px" */ <== NOTE E


Questions:
1. I know that element properties are linked to attributes in XBL or some other scripts/programs. However, why not make a single view of element attributes and element's style attributes (NOTE A) ? When I use XULElement.height, I expect to get the actual height of the element (i.e. 50, not 100 in NOTE C)


2. Why XULElement.style not implemented? I think that linking XULElement.style to document.defaultView.getComputedStyle(XULElement ele) is simple implementation. (NOTE B)

3. Assigning to XULElement's properties or attributes makes recomputing of styles, but I'm confused why vbox1Style.maxHeight (style's "max-height" attribute) does not reflect its actual value (50px, not 30px in NOTE D), while vbox1Style.height does (NOTE E).

Regards,
Wang Xianzhu






Reply via email to