Expando Properties

From GreaseSpot Wiki
Jump to: navigation, search

Expando Properties are attributes (of a DOM element in this case) which are not part of the standard definition.

Example: <div id="d1" test="true" onclick="myFunc();">...</div>

  • Here the id attribute is an officially defined attribute, settable and readable from the DOM at any time. XPCNativeWrappers transparently give access to this property.
  • The test attribute is a pure private invention. It is stored on the DOM object and can be read and changed through get/setAttribute calls. When using XPCNativeWrappers, the property is set on the wrapped object, not the underlying native DOM element.
  • The onclick attribute is not part of the official DOM specification. However, it is mapped to an internal event handler setter for backward compatibility with the so called DOM level 0 model. XPCNativeWrapper does not support this mapping and ignores the onclick property for the underlying DOM element.

The term Expando Properties refers to a global expando property (MSDN) on the document model of MS Internet Explorer since version 4.0.

The term seems to have a double meaning, as both the ad-hoc invented attribute name, as well as the wrapper functionality which some expando's have (e.g. onclick, which adds an event handler for the click event).