Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Revision 405073 of SVGLengthList

  • Revision slug: Web/API/SVGLengthList
  • Revision title: SVGLengthList
  • Revision id: 405073
  • Created:
  • Creator: Sheppy
  • Is current revision? No
  • Comment one or more formatting changesDOM/SVGLengthList Web/API/SVGLengthList

Revision Content

SVG length list interface

The SVGLengthList defines a list of {{ domxref("SVGLength") }} objects.

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

{{ gecko_callout_heading("5.0") }}

Starting in Gecko 5.0 {{ geckoRelease("5.0") }},the SVGLengthList DOM interface is now indexable and can be accessed like arrays

Interface overview

Also implement None
Methods
  • void clear()
  • {{ domxref("SVGLength") }} initialize(in {{ domxref("SVGLength") }} newItem)
  • {{ domxref("SVGLength") }} getItem(in unsigned long index)
  • {{ domxref("SVGLength") }} insertItemBefore(in {{ domxref("SVGLength") }} newItem, in unsigned long index)
  • {{ domxref("SVGLength") }} replaceItem(in {{ domxref("SVGLength") }} newItem, in unsigned long index)
  • {{ domxref("SVGLength") }} removeItem(in unsigned long index)
  • {{ domxref("SVGLength") }} appendItem(in {{ domxref("SVGLength") }} newItem)
Properties
  • readonly unsigned long numberOfItem
  • readonly unsigned long length {{ fx_minversion_inline(5.0) }} {{ non-standard_inline() }}
Normative document SVG 1.1 (2nd Edition)

Properties

Name Type Description
numberOfItem unsigned long The number of items in the list.
length {{ fx_minversion_inline(5.0) }} {{ non-standard_inline() }} unsigned long The number of items in the list.

Methods

Name & Arguments Return Description
clear() void

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

Exceptions:

  • a {{ domxref("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 {{ domxref("SVGLength") }} newItem) {{ domxref("SVGLength") }}

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 {{ domxref("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) {{ domxref("SVGLength") }}

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 {{ domxref("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 {{ domxref("SVGLength") }} newItem, in unsigned long index) {{ domxref("SVGLength") }}

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 {{ domxref("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 {{ domxref("SVGLength") }} newItem, in unsigned long index) {{ domxref("SVGLength") }}

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 {{ domxref("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 {{ domxref("DOMException") }} with code INDEX_SIZE_ERR is raised if the index number is greater than or equal to numberOfItems.
removeItem(in unsigned long index) {{ domxref("SVGLength") }}

Removes an existing item from the list.

Exceptions:

  • a {{ domxref("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 {{ domxref("DOMException") }} with code INDEX_SIZE_ERR is raised if the index number is greater than or equal to numberOfItems.
appendItem(in {{ domxref("SVGLength") }} newItem) {{ domxref("SVGLength") }}

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 {{ domxref("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

{{ CompatibilityTable() }}

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support {{ CompatUnknown() }} {{ CompatUnknown() }} {{ CompatUnknown() }} {{ CompatUnknown() }} {{ CompatUnknown() }}
Feature Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support {{ CompatNo() }} {{ CompatUnknown() }} {{ CompatUnknown() }} {{ CompatUnknown() }} {{ CompatUnknown() }}

Revision Source

<h2 id="SVG_length_list_interface">SVG length list interface</h2>
<p>The <code>SVGLengthList</code> defines a list of {{ domxref("SVGLength") }} objects.</p>
<p>An <code>SVGLengthList</code> object can be designated as read only, which means that attempts to modify the object will result in an exception being thrown.</p>
<div class="geckoVersionNote">
<p>{{ gecko_callout_heading("5.0") }}</p>
<p>Starting in Gecko 5.0 {{ geckoRelease("5.0") }},the <code>SVGLengthList</code> DOM interface is now indexable and can be accessed like arrays</p>
</div>
<h3 id="Interface_overview">Interface overview</h3>
<table class="standard-table"> <tbody> <tr> <th scope="row">Also implement</th> <td><em>None</em></td> </tr> <tr> <th scope="row">Methods</th> <td> <ul> <li><code>void clear()</code></li> <li>{{ domxref("SVGLength") }} <code>initialize(in {{ domxref("SVGLength") }} <em>newItem</em>)</code></li> <li>{{ domxref("SVGLength") }} <code>getItem(in unsigned long <em>index</em>)</code></li> <li>{{ domxref("SVGLength") }} <code>insertItemBefore(in {{ domxref("SVGLength") }} <em>newItem</em>, in unsigned long <em>index</em>)</code></li> <li>{{ domxref("SVGLength") }} <code>replaceItem(</code><code>in {{ domxref("SVGLength") }} <em>newItem</em>, in unsigned long <em>index</em></code><code>)</code></li> <li>{{ domxref("SVGLength") }} <code>removeItem(in unsigned long <em>index</em>)</code></li> <li>{{ domxref("SVGLength") }} <code>appendItem(in {{ domxref("SVGLength") }} <em>newItem</em>)</code></li> </ul> </td> </tr> <tr> <th scope="row">Properties</th> <td> <ul> <li>readonly unsigned long <code>numberOfItem</code></li> <li>readonly unsigned long <code>length</code> {{ fx_minversion_inline(5.0) }} {{ non-standard_inline() }}</li> </ul> </td> </tr> <tr> <th scope="row">Normative document</th> <td><a class="external" href="https://www.w3.org/TR/SVG11/types.html#InterfaceSVGLengthList" title="https://www.w3.org/TR/SVG11/types.html#InterfaceSVGLengthList">SVG 1.1 (2nd Edition)</a></td> </tr> </tbody>
</table><h2 id="Properties">Properties</h2>
<table class="standard-table"> <thead> <tr> <th>Name</th> <th>Type</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td><code>numberOfItem</code></td> <td>unsigned long</td> <td>The number of items in the list.</td> </tr> <tr> <td><code>length </code>{{ fx_minversion_inline(5.0) }} {{ non-standard_inline() }}</td> <td>unsigned long</td> <td>The number of items in the list.</td> </tr> </tbody>
</table>
<h2 id="Methods">Methods</h2>
<table class="standard-table"> <thead> <tr> <th>Name &amp; Arguments</th> <th>Return</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td><code><strong>clear</strong>()</code></td> <td><em>void</em></td> <td> <p>Clears all existing current items from the list, with the result being an empty list.</p> <p><strong>Exceptions:</strong></p> <ul> <li>a {{ domxref("DOMException") }} with code <code>NO_MODIFICATION_ALLOWED_ERR</code> is raised when the list corresponds to a read only attribute or when the object itself is read only.</li> </ul> </td> </tr> <tr> <td><code><strong>initialize</strong>(</code><code>in {{ domxref("SVGLength") }} <em>newItem</em></code><code>)</code></td> <td>{{ domxref("SVGLength") }}</td> <td> <p>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.</p> <p><strong>Exceptions:</strong></p> <ul> <li>a {{ domxref("DOMException") }} with code <code>NO_MODIFICATION_ALLOWED_ERR</code> is raised when the list corresponds to a read only attribute or when the object itself is read only.</li> </ul> </td> </tr> <tr> <td><code><strong>getItem</strong>(in unsigned long <em>index</em>)</code></td> <td>{{ domxref("SVGLength") }}</td> <td> <p>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.</p> <p><strong>Exceptions:</strong></p> <ul> <li>a {{ domxref("DOMException") }} with code <code>NO_MODIFICATION_ALLOWED_ERR</code> is raised when the list corresponds to a read only attribute or when the object itself is read only.</li> </ul> </td> </tr> <tr> <td><code><strong>insertItemBefore</strong>(in {{ domxref("SVGLength") }} <em>newItem</em>, in unsigned long <em>index</em>)</code></td> <td>{{ domxref("SVGLength") }}</td> <td> <p>Inserts a new item into the list at the specified position. The first item is number 0. If <code>newItem</code> 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 <code>index</code> 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 <code>numberOfItems</code>, then the new item is appended to the end of the list.</p> <p><strong>Exceptions:</strong></p> <ul> <li>a {{ domxref("DOMException") }} with code <code>NO_MODIFICATION_ALLOWED_ERR</code> is raised when the list corresponds to a read only attribute or when the object itself is read only.</li> </ul> </td> </tr> <tr> <td><code><strong>replaceItem</strong>(</code><code>in {{ domxref("SVGLength") }} <em>newItem</em>, in unsigned long <em>index</em></code><code>)</code></td> <td>{{ domxref("SVGLength") }}</td> <td> <p>Replaces an existing item in the list with a new item. If <code>newItem</code> 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.</p> <p><strong>Exceptions:</strong></p> <ul> <li>a {{ domxref("DOMException") }} with code <code>NO_MODIFICATION_ALLOWED_ERR</code> is raised when the list corresponds to a read only attribute or when the object itself is read only.</li> <li>a {{ domxref("DOMException") }} with code <code>INDEX_SIZE_ERR</code> is raised if the index number is greater than or equal to <code>numberOfItems</code>.</li> </ul> </td> </tr> <tr> <td><code><strong>removeItem</strong>(in unsigned long <em>index</em>)</code></td> <td>{{ domxref("SVGLength") }}</td> <td> <p>Removes an existing item from the list.</p> <p><strong>Exceptions:</strong></p> <ul> <li>a {{ domxref("DOMException") }} with code <code>NO_MODIFICATION_ALLOWED_ERR</code> is raised when the list corresponds to a read only attribute or when the object itself is read only.</li> <li>a {{ domxref("DOMException") }} with code <code>INDEX_SIZE_ERR</code> is raised if the index number is greater than or equal to <code>numberOfItems</code>.</li> </ul> </td> </tr> <tr> <td><code><strong>appendItem</strong>(in {{ domxref("SVGLength") }} <em>newItem</em>)</code></td> <td>{{ domxref("SVGLength") }}</td> <td> <p>Inserts a new item at the end of the list. If <code>newItem</code> 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.</p> <p><strong>Exceptions:</strong></p> <ul> <li>a {{ domxref("DOMException") }} with code <code>NO_MODIFICATION_ALLOWED_ERR</code> is raised when the list corresponds to a read only attribute or when the object itself is read only.</li> </ul> </td> </tr> </tbody>
</table>
<h2 id="Browser_compatibility" name="Browser_compatibility">Browser compatibility</h2>
<p>{{ CompatibilityTable() }}</p>
<div id="compat-desktop">
<table class="compat-table"> <tbody> <tr> <th>Feature</th> <th>Chrome</th> <th>Firefox (Gecko)</th> <th>Internet Explorer</th> <th>Opera</th> <th>Safari (WebKit)</th> </tr> <tr> <td>Basic support</td> <td>{{ CompatUnknown() }}</td> <td>{{ CompatUnknown() }}</td> <td>{{ CompatUnknown() }}</td> <td>{{ CompatUnknown() }}</td> <td>{{ CompatUnknown() }}</td> </tr> </tbody>
</table>
</div>
<div id="compat-mobile">
<table class="compat-table"> <tbody> <tr> <th>Feature</th> <th>Android</th> <th>Firefox Mobile (Gecko)</th> <th>IE Mobile</th> <th>Opera Mobile</th> <th>Safari Mobile</th> </tr> <tr> <td>Basic support</td> <td>{{ CompatNo() }}</td> <td>{{ CompatUnknown() }}</td> <td>{{ CompatUnknown() }}</td> <td>{{ CompatUnknown() }}</td> <td>{{ CompatUnknown() }}</td> </tr> </tbody>
</table>
</div>
Revert to this revision