The initial value of an attribute or property is the value used when that attribute or property is not specified, or when it has an invalid value. This value is to be used for the purposes of rendering, calculating animation values, and when accessing the attribute or property via DOM interfaces.
In this specification, attributes are defined with an attribute definition table, which looks like this:
Name | Value | Initial value | Animatable |
---|---|---|---|
exampleattr | <length> | none | none | yes |
In the Value column is a description of the attribute's syntax. There are six methods for describing an attribute's syntax:
SVG 2 Requirement: | Consider relaxing case sensitivity of presentation attribute values. |
---|---|
Resolution: | We will make property values case insensitivity. |
Purpose: | To align presentation attribute syntax parsing with parsing of the corresponding CSS property. |
Owner: | Cameron (ACTION-3276) |
When a presentation attribute defined using the CSS Value Definition Syntax is parsed, this is done as follows:
The insertion of the <number> symbols allows for unitless length and angles to be used in presentation attribute while disallowing them in corresponding property values.
Note that all presentation attributes, since they are defined by reference to their corresponding CSS properties, are defined using the CSS Value Definition Syntax.
When any other attribute defined using the CSS Value Definition Syntax is parsed, this is done by parsing the attribute's value according to the grammar given in attribute definition table.
Note that this allows CSS comments and escapes to be used in such attributes. For example, a value of '10\px/**/' would successfully parse as '10px' in the ‘x’ presentation attribute of the ‘rect’ element.
When an attribute defined as a URL is parsed, this is done by invoking the URL parser with the attribute's value as input and the document's URL as base [URL].
The Initial value column gives the initial value for the attribute. When an attribute fails to parse according to the specified CSS Value Definition Syntax, EBNF or EBNF grammar, or if parsing according to the URL Standard or by the prose describing how to parse the attribute indicates failure, the attribute is assumed to have been specified as the given initial value.
The initial value of a presentation attribute is its corresponding property's initial value. Since the use of an invalid value in a presentation attribute will be treated as if the initial value was specified, this value can override values that come from lower priority style sheet rules, such as those from the user agent style sheet.
For example, although the user agent style sheet sets the value of the
‘overflow
’ property to hidden
for ‘svg’ elements, specifying an invalid presentation attribute such
as overflow="invalid" will result
in a rule setting ‘overflow
’ to visible,
overriding the user agent style sheet value.
The Animatable column indicates whether the attribute can be animated using animation elements as defined in the SVG Animation module.
The following common definitions are used for attributes that are defined in terms of an EBNF grammar:
wsp ::= (#x9 | #x20 | #xA | #xC | #xD) comma-wsp ::= (wsp+ ","? wsp*) | ("," wsp*)
Unless stated otherwise, numeric values in SVG attributes and in properties that are defined to have an effect on SVG elements must support at least all finite IEEE 754 single-precision values.
It is recommended that higher precision floating point storage and computation be performed on operations such as coordinate system transformations to provide the best possible precision and to prevent round-off errors.
Conforming SVG Viewers are required to perform numerical computation in accordance with their conformance class, as described in Conformance Criteria.
All of the SVG DOM interfaces that correspond directly to elements in the SVG language (such as the SVGPathElement interface for the ‘path’ element) derive from the SVGElement interface.
The CSSOM specification augments SVGElement with a style IDL attribute, so that the ‘style’ attribute can be accessed in the same way as on HTML elements.
interface SVGElement : Element { [SameObject] readonly attribute SVGAnimatedString className; readonly attribute SVGSVGElement? ownerSVGElement; readonly attribute SVGElement? viewportElement; attribute long tabIndex; void focus(); void blur(); }; SVGElement implements GlobalEventHandlers;
The className IDL attribute reflects the ‘class’ attribute.
This attribute is deprecated and may be removed in a future version of this specification. Authors are advised to use Element.classList intead.
The ownerSVGElement IDL attribute represents the nearest ancestor ‘svg’ element. On getting ownerSVGElement, the nearest ancestor ‘svg’ element is returned; if the current element is the outermost svg element, then null is returned.
The viewportElement IDL attribute represents the element that provides the viewport for the current element. On getting viewport, the nearest ancestor element that establishes a viewport is returned; if the current element is the outermost svg element, then null is returned.
The tabIndex IDL attribute and the focus and blur methods are used to control focus on SVG elements in the document. Their behavior is the same as the corresponding IDL members on the HTMLElement interface.
As in HTML documents, the use of the blur method is discouraged. Authors are recommended to focus another element instead.
Authors are strongly suggested not to use the
blur method or any
other technique to hide the focus ring from keyboard users, such as
using a CSS rule to override the ‘outline
’ property.
Removal of the focus ring leads to serious accessibility issues for users who
navigate and interact with interactive content using the keyboard.
SVG 2 Requirement: | Detect if a mouse event is on the fill or stroke of a shape. |
---|---|
Resolution: | SVG 2 will make it easier to detect if an mouse event is on the stroke or fill of an element. |
Purpose: | To allow authors to discriminate between pointer events on the fill and stroke of an element without having to duplicate the element |
Owner: | Cameron (ACTION-3279) |
The SVGGraphicsElement interface represents SVG elements whose primary purpose is to directly render graphics into a group.
dictionary SVGBoundingBoxOptions { boolean fill = true; boolean stroke = false; boolean markers = false; boolean clipped = false; }; interface SVGGraphicsElement : SVGElement { [SameObject] readonly attribute SVGAnimatedTransformList transform; DOMRect getBBox(optional SVGBoundingBoxOptions options); DOMMatrix? getCTM(); DOMMatrix? getScreenCTM(); }; SVGGraphicsElement implements SVGTests;
The transform IDL attribute
reflects the computed value of the ‘transform
’ property and its
corresponding ‘transform’ presentation attribute.
The getBBox method is used to compute the bounding box of the current element. When the getBBox(options) method is called, the bounding box algorithm is invoked for the current element, with fill, stroke, markers and clipped members of the options dictionary argument used to control which parts of the element are included in the bounding box, using the element's local coordinate system as the coordinate system to return the bounding box in. A newly created DOMRect object that defines the computed bounding box is returned.
The getCTM method is used to get the matrix that transforms the current element's coordinate system to its viewport's coordinate system. When getCTM() is called, the following steps are run:
transform
’ property)
to the coordinate space of the document's viewport. The matrix includes the
transforms produced by the ‘viewBox’ and ‘preserveAspectRatio’
attributes, the ‘transform
’ property, and any transform
due to currentScale
and currentTranslate
properties on the SVGSVGElement.transform
’
property) to the coordinate space of its closest ancestor
viewport-establishing element (also including its ‘transform
’
property).The getScreenCTM method is used to get the matrix that transforms the current element's coordinate system to the coordinate system of the viewport for the SVG document fragment. When getScreenCTM() is called, the following steps are run:
transform
’ property)
to the coordinate space of the document's viewport.
This will include:
transform
’ property and any any transform
due to currentScale
and currentTranslate
properties on the SVGSVGElement for the outermost svg elementThis method would have been more aptly named as getClientCTM
,
but the name getScreenCTM
is kept for historical reasons.
Interface SVGGeometryElement represents SVG elements whose rendering is defined by geometry and which can be filled and stroked. This includes paths, text and the basic shapes.
interface SVGGeometryElement : SVGGraphicsElement { boolean isPointInFill(DOMPoint point); boolean isPointInStroke(DOMPoint point); };
pointer-events
’
property on the element determines whether a point is considered to be
within the fill.
pointer-events
’
property on the element determines whether a point is considered to be
within the stroke.
The SVGNumber interface is used primarily to represent a <number> value that is a part of an SVGNumberList. Individual SVGNumber objects can also be created by script.
An SVGNumber object can be designated as read only, which means that attempts to modify the object will result in an exception being thrown, as described below.
An SVGNumber object can be associated with a particular element. The associated element is used to determine which element's content attribute to update if the object reflects an attribute. Unless otherwise described, an SVGNumber object is not associated with any element.
Every SVGNumber object operates in one of three modes. It can:
An SVGNumber object maintains an internal number value, which is called its value.
interface SVGNumber { attribute float value; };
The value IDL attribute represents the number. On getting value, the SVGNumber's value is returned.
On setting value, the following steps are run:
The SVGNumber can't reflect an element of the animated value, since it would be read only and we would have thrown an exception in step 1.
The SVGLength interface is used to represent a value that can be a <length>, <percentage> or <number> value.
An SVGLength object can be designated as read only, which means that attempts to modify the object will result in an exception being thrown, as described below.
An SVGLength object can be associated with a particular element, as well as being designated with a directionality: horizontal, vertical or unspecified. The associated element and the directionality of the length are used to resolve percentage values to user units and is also used to determine which element's content attribute to update if the object reflects an attribute. Unless otherwise described, an SVGLength object is not associated with any element and has unspecified directionality.
Every SVGLength object operates in one of seven modes. It can:
An SVGLength object maintains an internal <length> or <percentage> or <number> value, which is called its value.
interface SVGLength { // Length Unit Types const unsigned short SVG_LENGTHTYPE_UNKNOWN = 0; const unsigned short SVG_LENGTHTYPE_NUMBER = 1; const unsigned short SVG_LENGTHTYPE_PERCENTAGE = 2; const unsigned short SVG_LENGTHTYPE_EMS = 3; const unsigned short SVG_LENGTHTYPE_EXS = 4; const unsigned short SVG_LENGTHTYPE_PX = 5; const unsigned short SVG_LENGTHTYPE_CM = 6; const unsigned short SVG_LENGTHTYPE_MM = 7; const unsigned short SVG_LENGTHTYPE_IN = 8; const unsigned short SVG_LENGTHTYPE_PT = 9; const unsigned short SVG_LENGTHTYPE_PC = 10; readonly attribute unsigned short unitType; attribute float value; attribute float valueInSpecifiedUnits; attribute DOMString valueAsString; void newValueSpecifiedUnits(unsigned short unitType, float valueInSpecifiedUnits); void convertToSpecifiedUnits(unsigned short unitType); };
The numeric length unit type constants defined on SVGLength are used to represent the type of an SVGLength's value. Their meanings are as follows:
Constant | Meaning |
---|---|
SVG_LENGTHTYPE_NUMBER | A unitless <number> interpreted as a value in px. |
SVG_LENGTHTYPE_PERCENTAGE | A <percentage>. |
SVG_LENGTHTYPE_EMS | A <length> with an em unit. |
SVG_LENGTHTYPE_EXS | A <length> with an ex unit. |
SVG_LENGTHTYPE_PX | A <length> with a px unit. |
SVG_LENGTHTYPE_CM | A <length> with a cm unit. |
SVG_LENGTHTYPE_MM | A <length> with a mm unit. |
SVG_LENGTHTYPE_IN | A <length> with an in unit. |
SVG_LENGTHTYPE_PT | A <length> with a pt unit. |
SVG_LENGTHTYPE_PC | A <length> with a pc unit. |
SVG_LENGTHTYPE_UNKNOWN | Some other type of value. |
The use of numeric length unit type constants is an anti-pattern and new constant values will not be introduced for any other units or length types supported by SVGLength. If other types of lengths are supported and used, the SVGLength uses the SVG_LENGTHTYPE_UNKNOWN unit type. See below for details on how the other properties of an SVGLength operate with these types of lengths.
The unitType IDL attribute represents the type of value that the SVGLength's value is. On getting unitType, the following steps are run:
For example, for a <length> with a ch unit or one that has a non-scalar value such as calc(), SVG_LENGTHTYPE_UNKNOWN would be returned.
The value IDL attribute represents the SVGLength's value in user units. On getting value, the following steps are run:
font-size
’ propertyfont-size
’ propertyOn setting value, the following steps are run:
The SVGLength can't reflect (an element of) the animated value, since it would be read only and we would have thrown an exception in step 1.
The valueInSpecifiedUnits IDL attribute represents the numeric factor of the SVGLength's value. On getting valueInSpecifiedUnits, the following steps are run:
Thus valueInSpecifiedUnits would return 12 for both '12%' and 12em, but 0 would be returned for non-scalar values like calc(12px + 5%).
On setting valueInSpecifiedUnits, the following steps are run:
The SVGLength can't reflect (an element of) the animated value, since it would be read only and we would have thrown an exception in step 1.
The valueAsString IDL attribute represents the SVGLength's value as a string. On getting valueAsString, the following steps are run:
On setting valueAsString, the following steps are run:
The SVGLength can't reflect (an element of) the animated value, since it would be read only and we would have thrown an exception in step 1.
The newValueSpecifiedUnits method is used to set the SVGLength's value in a typed manner. When newValueSpecifiedUnits(unitType, valueInSpecifiedUnits) is called, the following steps are run:
The SVGLength can't reflect (an element of) the animated value, since it would be read only and we would have thrown an exception in step 1.
The convertToSpecifiedUnits method is used to convert the SVGLength's value to a specific type. When convertToSpecifiedUnits(unitType) is called, the following steps are run:
font-size
’ propertyfont-size
’ propertyfont-size
’ basis.The SVGLength can't reflect (an element of) the animated value, since it would be read only and we would have thrown an exception in step 1.
The SVGAngle interface is used to represent a value that can be an <angle> or <number> value.
An SVGAngle object can be designated as read only, which means that attempts to modify the object will result in an exception being thrown, as described below.
An SVGAngle object can be associated with a particular element. The associated element is used to determine which element's content attribute to update if the object reflects an attribute. Unless otherwise described, an SVGAngle object is not associated with any element.
Every SVGAngle object operates in one of three modes. It can:
An SVGAngle object maintains an internal <angle> or <number> value, which is called its value.
interface SVGAngle { // Angle Unit Types const unsigned short SVG_ANGLETYPE_UNKNOWN = 0; const unsigned short SVG_ANGLETYPE_UNSPECIFIED = 1; const unsigned short SVG_ANGLETYPE_DEG = 2; const unsigned short SVG_ANGLETYPE_RAD = 3; const unsigned short SVG_ANGLETYPE_GRAD = 4; readonly attribute unsigned short unitType; attribute float value; attribute float valueInSpecifiedUnits; attribute DOMString valueAsString; void newValueSpecifiedUnits(unsigned short unitType, float valueInSpecifiedUnits); void convertToSpecifiedUnits(unsigned short unitType); };
The numeric angle unit type constants defined on SVGAngle are used to represent the type of an SVGAngle's value. Their meanings are as follows:
Constant | Meaning |
---|---|
SVG_ANGLETYPE_UNSPECIFIED | A unitless <number> interpreted as a value in degrees. |
SVG_ANGLETYPE_DEG | An <angle> with a deg unit. |
SVG_ANGLETYPE_RAD | An <angle> with a rad unit. |
SVG_ANGLETYPE_GRAD | An <angle> with a grad unit. |
SVG_ANGLETYPE_UNKNOWN | Some other type of value. |
The use of numeric angle unit type constants is an anti-pattern and new constant values will not be introduced for any other units or angle types supported by SVGAngle. If other types of angles are supported and used, the SVGAngle uses the SVG_ANGLETYPE_UNKNOWN unit type. See below for details on how the other properties of an SVGAngle operate with these types of angles.
The unitType IDL attribute represents the type of value that the SVGAngle's value is. On getting unitType, the following steps are run:
For example, for an <angle> with a turn unit, SVG_ANGLETYPE_UNKNOWN would be returned.
The value IDL attribute represents the SVGAngle's value in user units. On getting value, the following steps are run:
On setting value, the following steps are run:
The SVGAngle can't reflect the animated value, since it would be read only and we would have thrown an exception in step 1.
The valueInSpecifiedUnits IDL attribute represents the numeric factor of the SVGAngle's value. On getting valueInSpecifiedUnits, the following steps are run:
On setting valueInSpecifiedUnits, the following steps are run:
The SVGAngle can't reflect (an element of) the animated value, since it would be read only and we would have thrown an exception in step 1.
The valueAsString IDL attribute represents the SVGAngle's value as a string. On getting valueAsString, the following steps are run:
On setting valueAsString, the following steps are run:
The SVGAngle can't reflect (an element of) the animated value, since it would be read only and we would have thrown an exception in step 1.
The newValueSpecifiedUnits method is used to set the SVGAngle's value in a typed manner. When newValueSpecifiedUnits(unitType, valueInSpecifiedUnits) is called, the following steps are run:
The SVGAngle can't reflect (an element of) the animated value, since it would be read only and we would have thrown an exception in step 1.
The convertToSpecifiedUnits method is used to convert the SVGAngle's value to a specific type. When convertToSpecifiedUnits(unitType) is called, the following steps are run:
The SVGAngle can't reflect (an element of) the animated value, since it would be read only and we would have thrown an exception in step 1.
SVG 2 Requirement: | Make the SVGList* interfaces a bit more like other lists/arrays. |
---|---|
Resolution: | Add array style indexing and .length and .item to svg list types. |
Purpose: | To align with other array types (e.g. NodeList). Already implemented in Opera and Firefox. |
Owner: | Erik (ACTION-2975) |
Some SVG attributes contain lists of values, and to represent these values there are a number of SVG DOM list interfaces, one for each required element type – SVGNumberList, SVGLengthList, SVGPointList, SVGTransformList and SVGStringList. The first four are used to represent the base and animated components of SVGAnimatedNumberList, SVGAnimatedLengthList, SVGAnimatedPoints and SVGTransformList objects, while the fifth, SVGStringList, is used to reflect a few unanimated attributes that take a list of strings.
Most list interfaces take the following form:
interface SVGNameList { readonly attribute unsigned long length; readonly attribute unsigned long numberOfItems; void clear(); Type initialize(Type newItem); getter Type getItem(unsigned long index); Type insertItemBefore(Type newItem, unsigned long index); Type replaceItem(Type newItem, unsigned long index); Type removeItem(unsigned long index); Type appendItem(Type newItem); setter void (unsigned long index, Type newItem); };
where Name is a descriptive name for the list element's ("Number", "Length", "Point", "Transform" or "String") and Type is the IDL type of the list's elements (SVGNumber, SVGLength, DOMPoint, SVGTransform or DOMString).
The SVGTransformList interface takes the above form but has two additional methods on it.
All list interface objects apart from SVGTransformList
reflect either the base value or the animated value of a reflected content
attribute. SVGTransformList objects reflect either a presentation
attribute (‘transform’,
‘gradientTransform’ or ‘patternTransform’)
or reflect the computed value of the ‘transform
’ property.
All list interface objects are associated with a particular element.
Unlike SVGLength and similar objects, there are no "detached"
list interface objects.
A list interface object maintains an internal list of elements,
which is referred to in the text below simply as "the list".
The IDL attributes and methods are used to inspect and manipulate elements
of the list. The list can also be changed in response to
changes to the reflected content attribute and to animation of
the content attribute (or, for SVGTransformList objects,
in response to changes to the computed value of the ‘transform
’
property).
A list interface object can be designated as read only, which means that attempts to modify the object will result in an exception being thrown, as described below.
A list interface object is synchronized by running the following steps:
transform
’ property,
then value is the current computed value
of that property.transform
’ property), new length
is 0.Whenever a list element object is to be detached, the following steps are run, depending on the list element type:
Whenever a list element object is to be attached, the following steps are run, depending on the list element type:
transform
’ property value:
transform
’ property valueThe supported property indices of a list interface object is the set of all non-negative integers less than the length of the list.
The length and numberOfItems IDL attributes represents the length of the list, and on getting simply return the length of the list.
The clear method is used to remove all items in the list. When clear() is called, the following steps are run:
The initialize method is used to clear the list and add a single, specified value to it. When initialize(newItem) is called, the following steps are run:
The getItem method is used to get an item from the list at the specified position. When getItem(index) is called, the following steps are run:
Note that if the list's element type is an object type, such as SVGLength, then a reference to that object and not a copy of it is returned.
The insertItemBefore method is used to insert an element into the list at a specific position. When insertItemBefore(newItem, index) is called, the following steps are run:
The replaceItem method is used to replace an existing item in the list with a new item. When replaceItem(newItem, index) is called, the following steps are run:
The removeItem method is used to remove an item from the list. When removeItem(index) is called, the following steps are run:
The appendItem method is used to append an item to the end of the list. When appendItem(newItem) is called, the following steps are run:
The behavior of the indexed property setter is the same as that for the replaceItem method.
The SVGNumberList interface is a list interface whose elements are SVGNumber objects. An SVGNumberList object represents a list of numbers.
interface SVGNumberList { readonly attribute unsigned long length; readonly attribute unsigned long numberOfItems; void clear(); SVGNumber initialize(SVGNumber newItem); getter SVGNumber getItem(unsigned long index); SVGNumber insertItemBefore(SVGNumber newItem, unsigned long index); SVGNumber replaceItem(SVGNumber newItem, unsigned long index); SVGNumber removeItem(unsigned long index); SVGNumber appendItem(SVGNumber newItem); setter void (unsigned long index, SVGNumber newItem); };
The behavior of all of the interface members of SVGNumberList are defined in the List interfaces section above.
The SVGLengthList interface is a list interface whose elements are SVGLength objects. An SVGLengthList object represents a list of lengths.
interface SVGLengthList { readonly attribute unsigned long length; readonly attribute unsigned long numberOfItems; void clear(); SVGLength initialize(SVGLength newItem); getter SVGLength getItem(unsigned long index); SVGLength insertItemBefore(SVGLength newItem, unsigned long index); SVGLength replaceItem(SVGLength newItem, unsigned long index); SVGLength removeItem(unsigned long index); SVGLength appendItem(SVGLength newItem); setter void (unsigned long index, SVGLength newItem); };
The behavior of all of the interface members of SVGLengthList are defined in the List interfaces section above.
Some IDL attributes reflect the value of a content attribute or a property. The way this reflection is done depends on the type of the IDL attribute:
At a high level, the object's baseVal is used to reflect the value of the content attribute, while its animVal is used to reflect the current animated value of the attribute. For objects that reflect a CSS property, the baseVal is used to reflect the presentation attribute, and its animVal is used to reflect the computed value of the property.
Whenever:
then the reflecting object must be synchronized, immediately after the value changed, by running the following steps:
This will, for example, update the value of an SVGLength object.
When a reflected content attribute is to be reserialized, optionally using a specific value, the following steps must be performed:
This means that if the enumeration value is set to the "unknown" value, the content attribute will be set to the empty string.
The values will be SVGNumber, SVGLength, DOMPoint or SVGTransform objects, or DOMString values, depending on value's type.
An SVGAnimatedBoolean object is used to reflect an animatable attribute that takes a boolean value.
interface SVGAnimatedBoolean { attribute boolean baseVal; readonly attribute boolean animVal; };
The baseVal IDL attribute represents the current non-animated value of the reflected attribute. On getting baseVal, the following steps are run:
On setting baseVal, the reflected attribute is set to "true" if the value is true, and "false" otherwise.
The animVal IDL attribute represents the current animated value of the reflected attribute. On getting animVal, the following steps are run:
An SVGAnimatedEnumeration object is used to reflect an animatable attribute that takes a keyword value (such as the ‘method’ attribute on ‘textPath’) or to reflect the type of value that an animatable attribute has (done only by the orientType IDL attribute for the ‘marker’ element's ‘orient’ attribute).
interface SVGAnimatedEnumeration { attribute unsigned short baseVal; readonly attribute unsigned short animVal; };
For SVGAnimatedEnumeration objects that reflect an animatable attribute that takes only a keyword value, the baseVal IDL attribute represents the current non-animated value of the reflected attribute. For orientType, it represents the type of the current non-animated value of the reflected ‘orient’ attribute. On getting baseVal, the following steps are run:
On setting baseVal, the following steps are run:
For SVGAnimatedEnumeration objects that reflect an animatable attribute that takes only a keyword value, the animVal IDL attribute represents the current animated value of the reflected attribute. For orientType, it represents the type of the current animated value of the reflected ‘orient’ attribute. On getting animVal, the following steps are run:
An SVGAnimatedInteger object is used to reflect an animatable attribute that takes an integer value (such as ‘numOctaves’ on ‘feTurbulence’). It is also used to reflect one part of an animatable attribute that takes an integer followed by an optional second integer (such as ‘order’ on ‘feConvolveMatrix’).
This SVGAnimatedInteger interface is not used in this specification, however the Filter Effects specification has a number of uses of it.
interface SVGAnimatedInteger { attribute long baseVal; readonly attribute long animVal; };
For SVGAnimatedInteger objects that reflect an animatable attribute that takes a single integer value, the baseVal IDL attribute represents the current non-animated value of the reflected attribute. For those that reflect one integer of an attribute that takes an integer followed by an optional second integer, it represents the current non-animated value of one of the two integers. On getting baseVal, the following steps are run:
For example, the definition of ‘order’ says that the implicit second integer is the same as the explicit first integer.
On setting baseVal, the following steps are run:
For SVGAnimatedInteger objects that reflect an animatable attribute that takes a single integer value, the animVal IDL attribute represents the current animated value of the reflected attribute. For those that reflect one integer of an attribute that takes an integer followed by an optional second integer, it represents the current animated value of one of the two integers. On getting animVal, the following steps are run:
An SVGAnimatedNumber object is used to reflect an animatable attribute that takes a number value (such as ‘pathLength’ on ‘path’). It is also used to reflect one part of an animatable attribute that takes an number followed by an optional second number (such as ‘kernelUnitLength’ on ‘feDiffuseLighting’).
interface SVGAnimatedNumber { attribute float baseVal; readonly attribute float animVal; };
For SVGAnimatedNumber objects that reflect an animatable attribute that takes a single number value, the baseVal IDL attribute represents the current non-animated value of the reflected attribute. For those that reflect one number of an attribute that takes an number followed by an optional second number, it represents the current non-animated value of one of the two numbers. On getting baseVal, the following steps are run:
For example, the definition of ‘kernelUnitLength’ says that the implicit second number is the same as the explicit first number.
On setting baseVal, the following steps are run:
For SVGAnimatedNumber objects that reflect an animatable attribute that takes a single number value, the animVal IDL attribute represents the current animated value of the reflected attribute. For those that reflect one number of an attribute that takes an number followed by an optional second number, it represents the current animated value of one of the two numbers. On getting animVal, the following steps are run:
An SVGAnimatedLength object is used to reflect either (a) an animatable attribute that takes a <length>, <percentage> or <number> value, or (b) the computed value of a CSS property that takes one of these values and its corresponding presentation attribute.
interface SVGAnimatedLength { [SameObject] readonly attribute SVGLength baseVal; [SameObject] readonly attribute SVGLength animVal; };
The baseVal IDL attribute represents the current value of the reflected content attribute. On getting baseVal, an SVGLength object is returned that:
The animVal IDL attribute represents the current animated value of the reflected attribute or the computed value of the reflected property. On getting animVal, an SVGLength object is returned that:
The objects returned from baseVal and animVal must be distinct, even if there is no animation currently affecting the attribute.
An SVGAnimatedAngle object is used to reflect the <angle> value of the animated ‘orient’ attribute on ‘marker’, through the orientAngle IDL attribute.
interface SVGAnimatedAngle { [SameObject] readonly attribute SVGAngle baseVal; [SameObject] readonly attribute SVGAngle animVal; };
The baseVal IDL attribute represents the current non-animated <angle> value of the reflected ‘orient’ attribute. On getting baseVal, an SVGAngle object is returned that:
The animVal IDL attribute represents the current animated <angle> value of the reflected ‘orient’ attribute. On getting animVal, an SVGAngle object is returned that:
The objects returned from baseVal and animVal must be distinct, even if there is no animation currently affecting the attribute.
An SVGAnimatedString object is used to reflect an animatable attribute that takes a string value. It can optionally be defined to additionally reflect a second, deprecated attribute.
interface SVGAnimatedString { attribute DOMString baseVal; readonly attribute DOMString animVal; };
The baseVal IDL attribute represents the current non-animated value of the reflected attribute. On getting baseVal, the following steps are run:
For the href member on the SVGURIReference interface, this will result in the deprecated ‘xlink:href’ attribute being returned if it is present and the ‘href’ attribute is not, and in the ‘href’ attribute being returned in all other cases.
On setting baseVal, the following steps are run:
For the href member on the SVGURIReference interface, this will result in the deprecated ‘xlink:href’ attribute being set if it is present and the ‘href’ attribute is not, and in the ‘href’ attribute being set in all other cases.
The animVal IDL attribute represents the current animated value of the reflected attribute. On getting animVal, the following steps are run:
Animation elements treat targetting the ‘xlink:href’ attribute as an animation targetting ‘href’, so there is no animated ‘xlink:href’ value to return from animVal.
An SVGAnimatedRect object is used to reflect an animatable attribute that takes a rectangle value as specified by an x, y, width and height.
In this specification the only attribute to be reflected as an SVGAnimatedRect is ‘viewBox’.
interface SVGAnimatedRect { [SameObject] readonly attribute DOMRect baseVal; [SameObject] readonly attribute DOMRectReadOnly animVal; };
The baseVal IDL attribute represents the current non-animated rectangle value of the reflected attribute. On getting baseVal, a DOMRect object is returned.
Upon creation of the baseVal DOMRect object, and afterwards whenever the reflected content attribute is added, removed, or changed, the following steps are run:
Whenever the x coordinate, y coordinate, width or height property of the baseVal DOMRect object changes, except as part of the previous algorithm that reflects the value of the content attribute into the DOMRect, the reflected content attribute must be reserialized.
The animVal IDL attribute represents the current animated rectangle value of the reflected attribute. On getting animVal, a DOMRectReadOnly object is returned.
Upon creation of the animVal DOMRect object, and afterwards whenever the reflected content attribute is added, removed, or changed, or an animation starts or stops applying to the attribute, or when a new animated value is given to the attribute due to an animation tick, the following steps are run:
The objects returned from baseVal and animVal must be distinct, even if there is no animation currently affecting the attribute.
An SVGAnimatedNumberList object is used to reflect an animatable attribute that takes a list of <number> values.
interface SVGAnimatedNumberList { [SameObject] readonly attribute SVGNumberList baseVal; [SameObject] readonly attribute SVGNumberList animVal; };
The baseVal IDL attribute represents the current non-animated value of the reflected attribute. On getting baseVal, an SVGNumberList object is returned that reflects the base value of the reflected attribute.
The animVal IDL attribute represents the current non-animated value of the reflected attribute. On getting animVal, an SVGNumberList object is returned that reflects the animated value of the reflected attribute.
The objects returned from baseVal and animVal must be distinct, even if there is no animation currently affecting the attribute.
An SVGAnimatedLengthList object is used to reflect an animatable attribute that takes a list of <length>, <percentage> or <number> values.
interface SVGAnimatedLengthList { [SameObject] readonly attribute SVGLengthList baseVal; [SameObject] readonly attribute SVGLengthList animVal; };
The baseVal IDL attribute represents the current non-animated value of the reflected attribute. On getting baseVal, an SVGLengthList object is returned that reflects the base value of the reflected attribute.
The animVal IDL attribute represents the current non-animated value of the reflected attribute. On getting animVal, an SVGLengthList object is returned that reflects the animated value of the reflected attribute.
The objects returned from baseVal and animVal must be distinct, even if there is no animation currently affecting the attribute.
The SVGStringList interface is a list interface whose elements are DOMString values. An SVGStringList object represents a list of strings.
interface SVGStringList { readonly attribute unsigned long length; readonly attribute unsigned long numberOfItems; void clear(); DOMString initialize(DOMString newItem); getter DOMString getItem(unsigned long index); DOMString insertItemBefore(DOMString newItem, unsigned long index); DOMString replaceItem(DOMString newItem, unsigned long index); DOMString removeItem(unsigned long index); DOMString appendItem(DOMString newItem); setter void (unsigned long index, DOMString newItem); };
The behavior of all of the interface members of SVGStringList are defined in the List interfaces section above.
The SVGUnitTypes interface defines a commonly used set of constants used for reflecting ‘gradientUnits’, ‘patternContentUnits’ and other similar attributes. It is mixed in to other interfaces for elements that support such attributes.
[NoInterfaceObject] interface SVGUnitTypes { // Unit Types const unsigned short SVG_UNIT_TYPE_UNKNOWN = 0; const unsigned short SVG_UNIT_TYPE_USERSPACEONUSE = 1; const unsigned short SVG_UNIT_TYPE_OBJECTBOUNDINGBOX = 2; };
The unit type constants defined on SVGUnitTypes have the following meanings:
Constant | Meaning |
---|---|
SVG_UNIT_TYPE_USERSPACEONUSE | Corresponds to the 'userSpaceOnUse' attribute value. |
SVG_UNIT_TYPE_OBJECTBOUNDINGBOX | Corresponds to the 'objectBoundingBox' attribute value. |
SVG_UNIT_TYPE_UNKNOWN | Some other type of value. |
The SVGTests interface is used to reflect conditional processing attributes, and is mixed in to other interfaces for elements that support these attributes.
[NoInterfaceObject] interface SVGTests { [SameObject] readonly attribute SVGStringList requiredExtensions; [SameObject] readonly attribute SVGStringList systemLanguage; };
The requiredExtensions IDL attribute reflects the ‘requiredExtensions’ content attribute.
The systemLanguage IDL attribute reflects the ‘systemLanguage’ content attribute.
The SVGFitToViewBox interface is used to reflect the ‘viewBox’ and ‘preserveAspectRatio’ attributes, and is mixed in to other interfaces for elements that support these two attributes.
[NoInterfaceObject] interface SVGFitToViewBox { [SameObject] readonly attribute SVGAnimatedRect viewBox; [SameObject] readonly attribute SVGAnimatedPreserveAspectRatio preserveAspectRatio; };
The viewBox IDL attribute reflects the ‘viewBox’ content attribute.
The preserveAspectRatio IDL attribute reflects the ‘preserveAspectRatio’ content attribute.
The SVGZoomAndPan interface is used to reflect the ‘zoomAndPan’ attribute, and is mixed in to other interfaces for elements that support this attribute.
[NoInterfaceObject] interface SVGZoomAndPan { // Zoom and Pan Types const unsigned short SVG_ZOOMANDPAN_UNKNOWN = 0; const unsigned short SVG_ZOOMANDPAN_DISABLE = 1; const unsigned short SVG_ZOOMANDPAN_MAGNIFY = 2; attribute unsigned short zoomAndPan; };
The zoom and pan type constants defined on SVGZoomAndPan have the following meanings:
Constant | Meaning |
---|---|
SVG_ZOOMANDPAN_DISABLE | Corresponds to the 'disable' attribute value. |
SVG_ZOOMANDPAN_MAGNIFY | Corresponds to the 'magnify' attribute value. |
SVG_ZOOMANDPAN_UNKNOWN | Some other type of value. |
The zoomAndPan IDL attribute represents the value of the ‘zoomAndPan’ attribute. On getting zoomAndPan, the following steps are run:
On setting zoomAndPan, the following steps are run:
The SVGURIReference interface is used to reflect the ‘href’ attribute and the deprecated ‘xlink:href’ attribute.
[NoInterfaceObject] interface SVGURIReference { [SameObject] readonly attribute SVGAnimatedString href; };
The href IDL attribute represents the value of the ‘href’ attribute, and, on elements that are defined to support it, the deprecated ‘xlink:href’ attribute. On getting href, an SVGAnimatedString object is returned that:
The SVGAnimatedString interface is defined to reflect through its baseVal member the deprecated ‘xlink:href’ attribute, if that attribute is present and the ‘href’ is not, and to reflect the ‘href’ attribute in all other circumstances. The animVal attribute reflects the animated value of the ‘href’ attribute. Animation elements treat attributeName='xlink:href' as being an alias for targetting the ‘href’ attribute.