SVGElementInstance object
Represents a single node in the instance tree (or shadow tree) that the SVG DOM maintains.
![]() ![]() |
Members
The SVGElementInstance object has these types of members:
Methods
The SVGElementInstance object has these methods.
| Method | Description |
|---|---|
| addEventListener |
Registers an event handler for the specified event type. |
| addEventListener |
Registers an event listener |
| dispatchEvent |
Sends an event to the current element. |
| dispatchEvent |
Dispatches an event to an object. |
| removeEventListener |
Removes an event handler that the addEventListener method registered. |
| removeEventListener |
Removes an event listener. |
Properties
The SVGElementInstance object has these properties.
| Property | Description |
|---|---|
|
Gets an SVGElementInstanceList object that contains all children of this SVGElementInstance object within the instance tree. | |
|
Gets the corresponding element that this object is an instance of. | |
|
Gets the corresponding use element that this object belongs to. | |
|
Gets the first child of this SVGElementInstance object in the instance tree. | |
|
Gets the last child of this SVGElementInstance object in the instance tree. | |
|
Gets the SVGElementInstance object that immediately follows this SVGElementInstance object. | |
|
Gets the parent of this SVGElementInstance object within the instance tree. | |
|
Gets the SVGElementInstance object that immediately precedes this SVGElementInstance object. |
Standards information
- Scalable Vector Graphics: Document Structure, Section 5.11.9
Remarks
The root object in the instance tree is pointed to by the instanceRoot attribute on the SVGUseElement object for the corresponding use element.
If the use element references a simple graphics element such as rect, there is only one SVGElementInstance object, and the correspondingElement attribute on this SVGElementInstance object is the SVGRectElement that corresponds to the referenced rect element.
If the use element references a g element that contains two rect elements, the instance tree contains three SVGElementInstance objects: a root SVGElementInstance object whose correspondingElement attribute is the SVGGElement object for the g element, and then two child SVGElementInstance objects that have their correspondingElement attribute that is an SVGRectElement object.
If the referenced object is a use element, or if there are use subelements within the referenced object, the instance tree contains a recursive expansion of the indirect references to form a complete tree. For example, if a use element references a g element, and the g element contains a use element, and that use element references a rect element, the instance tree for the original (outermost) use consists of a hierarchy of SVGElementInstance objects, as follows:
SVGElementInstance #1 (parentNode=null, firstChild=#2, correspondingElement is the 'g')
SVGElementInstance #2 (parentNode=#1, firstChild=#3, correspondingElement is the other 'use')
SVGElementInstance #3 (parentNode=#2, firstChild=null, correspondingElement is the 'rect')

