GWT setSize(): Do not use “inherit”

Widgets in GWT are essentially elements in the DOM tree of a web document. GWT widgets enable convenient control over these elements. For instance, a call of the widget method setSize(String width, String height) will set the dimensions of the HTML element underlying the widgets. Values to define the size can be anything allowed in HTML and CSS.

Possible values are:

  • “100px”
  • “50%”
  • “15em”
  • “auto”
  • “inherit”
  • Etc.

However, using convenience methods such as Widget.setSize() mindlessly can easily lead to serious bugs.

In particular, the code widget.setSize(“inherit”, “inherit”) will compile without errors or warnings. However, when loading the compiled JavaScript in Internet Explorer, a cryptic JavaScript error will occur. This is caused by Internet Explorer’s lack of support for the inheritance of attributes (also for font-size etc.).

Resources

How-to inherit CSS width attributes for Internet Explorer“, Kevin Deldycke’s blog

IE7 CSS inherit problem“, stackoverflow.com

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s