SVGStringList

SVG string list interface

The SVGStringList defines a list of DOMString objects.

An SVGStringList object can be designated as read only, which means that attempts to modify the object will result in an exception being thrown.

Interface overview

Also implement None
Methods
Properties
  • readonly unsigned long numberOfItems
  • readonly unsigned long length
Normative document SVG 1.1 (2nd Edition)

Properties

Name Type Description
numberOfItems unsigned long The number of items in the list.
length unsigned long A mirror of the value in numberOfItems, for consistency with other interfaces.

Methods

Name & Arguments Return Description
clear() void

Clears all existing current items from the list, with the result being an empty list.

Exceptions:

  • a DOMException with code NO_MODIFICATION_ALLOWED_ERR is raised when the list corresponds to a read only attribute or when the object itself is read only.
initialize(in DOMString newItem) DOMString

Clears all existing current items from the list and re-initializes the list to hold the single item specified by the parameter. If the inserted item is already in a list, it is removed from its previous list before it is inserted into this list. The inserted item is the item itself and not a copy. The return value is the item inserted into the list.

Exceptions:

  • a DOMException with code NO_MODIFICATION_ALLOWED_ERR is raised when the list corresponds to a read only attribute or when the object itself is read only.
getItem(in unsigned long index) DOMString

Returns the specified item from the list. The returned item is the item itself and not a copy. Any changes made to the item are immediately reflected in the list. The first item is number 0.

Exceptions:

  • a DOMException with code NO_MODIFICATION_ALLOWED_ERR is raised when the list corresponds to a read only attribute or when the object itself is read only.
insertItemBefore(in DOMString newItem, in unsigned long index) DOMString

Inserts a new item into the list at the specified position. The first item is number 0. If newItem is already in a list, it is removed from its previous list before it is inserted into this list. The inserted item is the item itself and not a copy. If the item is already in this list, note that the index of the item to insert before is before the removal of the item. If the index is equal to 0, then the new item is inserted at the front of the list. If the index is greater than or equal to numberOfItems, then the new item is appended to the end of the list.

Exceptions:

  • a DOMException with code NO_MODIFICATION_ALLOWED_ERR is raised when the list corresponds to a read only attribute or when the object itself is read only.
replaceItem(in DOMString newItem, in unsigned long index) DOMString

Replaces an existing item in the list with a new item. If newItem is already in a list, it is removed from its previous list before it is inserted into this list. The inserted item is the item itself and not a copy. If the item is already in this list, note that the index of the item to replace is before the removal of the item.

Exceptions:

  • a DOMException with code NO_MODIFICATION_ALLOWED_ERR is raised when the list corresponds to a read only attribute or when the object itself is read only.
  • a DOMException with code INDEX_SIZE_ERR is raised if the index number is greater than or equal to numberOfItems.
removeItem(in unsigned long index) DOMString

Removes an existing item from the list.

Exceptions:

  • a DOMException with code NO_MODIFICATION_ALLOWED_ERR is raised when the list corresponds to a read only attribute or when the object itself is read only.
  • a DOMException with code INDEX_SIZE_ERR is raised if the index number is greater than or equal to numberOfItems.
appendItem(in DOMString newItem) DOMString

Inserts a new item at the end of the list. If newItem is already in a list, it is removed from its previous list before it is inserted into this list. The inserted item is the item itself and not a copy.

Exceptions:

  • a DOMException with code NO_MODIFICATION_ALLOWED_ERR is raised when the list corresponds to a read only attribute or when the object itself is read only.

Browser compatibility

DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
SVGStringListChrome Full support YesEdge Full support 12Firefox Full support 12
Notes
Full support 12
Notes
Notes Since version 13, SVGStringList is indexable like Array which is a non-standard behavior.
IE Full support 9Opera Full support YesSafari Full support YesWebView Android Full support YesChrome Android Full support YesFirefox Android Full support 14
Notes
Full support 14
Notes
Notes SVGStringList is indexable like Array which is a non-standard behavior.
Opera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yes
length
Non-standard
Chrome Full support YesEdge Full support ≤79Firefox Full support 13IE ? Opera Full support YesSafari ? WebView Android Full support YesChrome Android Full support YesFirefox Android Full support 14Opera Android Full support YesSafari iOS ? Samsung Internet Android Full support Yes

Legend

Full support
Full support
Compatibility unknown
Compatibility unknown
Non-standard. Expect poor cross-browser support.
Non-standard. Expect poor cross-browser support.
See implementation notes.
See implementation notes.