SPHPlayground API
SPHPlayground
sphplayground sphplayground

HTML attribute management

BASIC INFORMATION:

An HTML attribute is a modifier of an HTML element. Particular attributes are only supported by particular element types.

Some attributes are required attributes, needed by particular element types for them to function correctly; while in other cases they are optional attributes. Standard attributes are supported by a large number of element types.

Implementation

All HTML attributes implement Attribute interface.

Instantiable attribute classes:

Invalid value ('foo') for 'type' attribute

Attribute management with an AttributeContainer

The AttributeContainer provides methods for creating, storing and manipulating Attribute objects. It is used in all of the HTML components as the attribute handler.

Basic AttributeContainer methods:

  1. setAttribute(): sets an attribute object
  2. remove(): removes an attribute if possible
  3. protect(): This method locks an attribute to a given value. Such attribute cannot be removed and locked value is immune to modification.

IMPORTANT NOTES ABOUT REQUIRING AND VALUE LOCKING!:

  1. As default the style and class attributes can have multiple locked values (Style properties and CSS class names) at the same time and only the locked .
  2. other attributes can have only one value as locked at the same time.
  3. Attribute can be required and have a locked value at the same time.