The initial value of an attribute or property is the value used when that attribute or property is not specified, or when it has aninvalid value. This value is to be used for the purposes of rendering, calculatinganimation values, and when accessing the attribute or property via DOM interfaces.
In this specification, attributes are defined with an attribute definitiontable, 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 aresix 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) |
Status: | Done |
When apresentation attributedefined using the CSS Value Definition Syntax is parsed, this is done asfollows:
The insertion of the<number> symbols allows forunitless length and angles to be used in presentation attribute whiledisallowing them in corresponding property values.
Note that allpresentation attributes, since they aredefined by reference to their corresponding CSS properties, are defined usingthe CSS Value Definition Syntax.
When any other attribute defined using the CSS ValueDefinition Syntax is parsed, this is done byparsing theattribute's value according to the grammar given in attribute definitiontable.
Note that this allows CSS comments and escapes to be usedin such attributes. For example, a value of'10\px/**/'would successfully parse as'10px' inthe‘x’ presentation attribute of the‘rect’ element.
When an attribute defined as a URL is parsed, this isdone by invoking theURL parser withthe attribute's value asinput and the document's URL asbase [URL].
The Initial value column gives theinitial value for the attribute.When an attribute fails to parse according to the specified CSS Value Definition Syntax,ABNF or EBNF grammar, or if parsing according to the URL Standardor by the prose describing how to parse the attribute indicates failure,the attribute is assumed to have been specified as the giveninitial value.
The initial value of apresentation attribute is its corresponding property's initial value. Since the use of aninvalid value in apresentation 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 theoverflow property tohidden for‘svg’ elements, specifying an invalid presentation attribute such asoverflow="invalid" will result in a rule settingoverflow tovisible, overriding the user agent style sheet value.
The Animatable column indicates whether the attribute can be animated usinganimation elements as defined in theSVG Animation module.
Unless stated otherwise, numeric values in SVG attributes and inproperties that are defined to have an effect on SVG elements mustsupport at least all finite single-precision values supported by the hostarchitecture.
It is recommended that higher precision floating pointstorage and computation be performed on operations such ascoordinate system transformations to provide the bestpossible precision and to prevent round-off errors.
conforming SVG viewersare required to perform numerical computation in accordance with theirconformance class, as described inConformance Criteria.
Some numeric attribute and property values have restricted ranges.Other values will be restricted by the capabilities of the device.If not otherwise specified,the user agent shall defer any out-of-range error checking untilas late as possible in the rendering process.This is particularly important for device limitations,as compound operationsmight produce intermediate values which are out-of-range butfinal values which are within range.
ConformingSVG viewers orSVG interpretersthat supportscript executionmust implement SVG DOM interfaces as defined throughout this specification,with the specific requirements and dependencies listed in this section.
SVG 2 Requirement: | Improve the DOM. |
---|---|
Resolution: | We will generally improve the SVG DOM for SVG 2. |
Purpose: | Help authors use the SVG DOM by making it less Java-oriented. |
Owner: | Cameron (ACTION-3273) |
Note: | SeeSVG 2 DOM Wiki page. |
SVG 2 Requirement: | Improve the SVG path DOM APIs. |
---|---|
Resolution: | We will improve the SVG path DOM APIs in SVG 2. |
Purpose: | Clean up SVGPathSegList interface, and possibly share an API with Canvas. |
Owner: | Cameron (no action) |
The SVG DOM is defined in terms ofWeb IDLinterfaces. All IDL fragments in this specification must be interpreted asrequired forconforming IDL fragments,as described in the Web IDL specification. [WebIDL]
The SVG DOM builds upon a number of DOM specifications. In particular:
The SVG DOM follows similar naming conventions to HTML and DOM standards([HTML], [DOM]).
All names are defined as one or more English wordsconcatenated together to form a single string. Property ormethod names start with the initial keyword in lowercase, andeach subsequent word starts with a capital letter. For example,a property that returns document meta information such as thedate the file was created might be named "fileDateCreated".
Interface names defined in this specification nearly all start with "SVG".Interfaces that represent the DOMElement objectfor an SVG-namespaced element follow the formatSVGElementNameElement
, whereElementName
is the element's tag name with the initial letter capitalized.SoSVGRadialGradientElement is the interface for an‘radialGradient’ element.
An exception to this casing convention isSVGSVGElement,in which the entire tag name is capitalized.
Any SVG software that is required to support the SVG DOMmust enhance the DOM elements created forSVG document fragmentsas follows:
EveryElement object that corresponds to a supported SVG element (that is,an element with namespace URI "http://www.w3.org/2000/svg" and alocal name that is one of the elements defined in this specificationor another specification implemented by the software)must also implement the DOM interface identified in the element definition.
Elements in the SVG namespace whose local name does not match an elementdefined in any specification supported by the softwareshould instead implement theSVGUnknownElement interface andmust nonetheless implement theSVGElement interface.
TheSVGUnknownElement interface is "at risk".
InThe‘rect’ element,theSVGRectElement interface is identified. This means that everyElement object whose namespace URI is "http://www.w3.org/2000/svg"and whose local name is "rect" must also implementSVGRectElement.
Many SVG DOM properties (IDL attributes)reflect a content attribute or propertyon the corresponding element,meaning that content and IDL attributes represent the same underlying data.For example,theSVGAnimatedLengthry in anSVGRectElementreflects thery presentation attribute on the associated‘rect’ element.
The way this reflection is done depends on the type of the IDL attribute:
At a high level, the object'sbaseVal
is used to reflect the value of the content attribute. For objects that reflect a CSS property, thebaseVal
is used to reflect the presentation attribute.
This relationship is live, and values must be synchronized(following the rules inSynchronizing reflected values)when either the attribute or its reflected property is modified.
If the attribute hasn't been specified explicitly in the document markup,the reflected object is nonetheless intialized upon access,to the attribute's inital value.If the attribute's initial value is(none),the object is initialized as defined inReflecting an empty initial value.This newly constructed object does not generate an attribute on the element untilit is modified for the first time. Modifications made to the correspondingattribute are immediately reflected in the object.
IflineElement.x1.baseVal
is accessed(wherelineElement
is an instance ofSVGLineElement)and the‘x1’ attribute was not specified in the document, thereturnedSVGLength object would represent the value0 user units,because the initial value for the attribute is0.
Whenever a reflected content attribute's base value changes,then the reflecting object must besynchronized,immediately after the value changed, by running the following steps:
This will, for example, update thevalue of anSVGLength object.
When areflected content attribute is to bereserialized, optionally using aspecific 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 beSVGNumber,SVGLength,DOMPoint orSVGTransform objects, orDOMString values, depending onvalue's type.
When initializing an SVG DOM attribute thatreflects a null or empty initial value,then the property must be initialized according to its data type,as defined in this section.This occurs only if there is no explicit value for the reflected content attribute,and the initial value in the attribute's definition table is(none).
If an interface is not listed below that meansthat the object initialization shall be done using the values for theobjects that the interface contains, e.g.,anSVGAnimatedString consists of twoDOMString members,while aDOMRect consists of manydoubles.
IftextElement.dx.baseVal
is accessed(wheretextElement
is an instance ofSVGTextElement)and the‘dx’ attribute was not specified in the document, thereturnedSVGLengthList object would be empty.
If a script sets areflected DOM attributeto aninvalid value for the content attribute (e.g.,a negative number for an attribute that requires a non-negativenumber or an out-of-range value for an enumeration), unlessthis specification indicates otherwise, no exception shall beraised on setting, but the given document fragment shall becometechnicallyin error as described inError processing.
Many browsers currently throw errors for out-of-range enumeration values, or explicitly setting an enumeration to the UNKNOWN value. SeeShould setting an enum IDL to an invalid value throw an error? on GitHub for discussion.
All of the SVG DOM interfaces that correspond directly to elements in theSVG language (such as theSVGPathElement interface for the‘path’ element) derive from theSVGElement interface.
The CSSOM specificationaugmentsSVGElement with a style IDL attribute, so that the‘style’attribute can be accessed in the same way as on HTML elements.
[Exposed=Window]interfaceSVGElement :Element { [SameObject] readonly attributeSVGAnimatedStringclassName; readonly attributeSVGSVGElement?ownerSVGElement; readonly attributeSVGElement?viewportElement;};SVGElement includesGlobalEventHandlers;SVGElement includesDocumentAndElementEventHandlers;SVGElement includesSVGElementInstance;SVGElement includesHTMLOrSVGElement;
TheclassName IDL attributereflects the‘class’ attribute.
This attribute is deprecated and may be removed in afuture version of this specification. Authors are advised to useElement.classList intead.
TheclassNameattribute onSVGElement overrides the correspond attribute onElement, following the WebIDL rules forinheritance.
TheownerSVGElement IDL attributerepresents the nearest ancestor‘svg’ element. On gettingownerSVGElement,the nearest ancestor‘svg’ element is returned; if the currentelement is theoutermost svg element, then null is returned.
TheviewportElement IDL attributerepresents the element that provides the SVG viewport for the current element. On gettingviewport,the nearest ancestor element that establishes an SVG viewport is returned; if the currentelement is theoutermost svg element, then null is returned.
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) |
Status: | Done. |
TheSVGGraphicsElement interface represents SVG elements whose primary purposeis to directly render graphics into a group.
dictionarySVGBoundingBoxOptions { boolean fill = true; boolean stroke = false; boolean markers = false; boolean clipped = false;};interfaceSVGGraphicsElement :SVGElement { [SameObject] readonly attributeSVGAnimatedTransformListtransform;DOMRectgetBBox(optionalSVGBoundingBoxOptions options);DOMMatrix?getCTM();DOMMatrix?getScreenCTM();};SVGGraphicsElement includesSVGTests;
Thetransform IDL attributereflects the computed value of thetransform property and itscorresponding‘transform’ presentation attribute.
ThegetBBox method is usedto compute the bounding box of the current element. When the getBBox(options)method is called, thebounding box algorithmis invoked for the current element,withfill,stroke,markersandclipped members of theoptions dictionary argumentused to control which parts of the element are included in the bounding box,using the element's user coordinate system as the coordinate system to return thebounding box in. A newly createdDOMRect object that defines thecomputed bounding box is returned.
ThegetCTM method is used toget the matrix that transforms the current element's coordinate system toits SVG viewport's coordinate system. When getCTM() is called, the followingsteps are run:
ThegetScreenCTM methodis used to get the matrix that transforms the current element's coordinatesystem to the coordinate system of the SVG viewport for the SVG document fragment.When getScreenCTM() is called, the following steps are run:
This will include:
This method would have been more aptly named asgetClientCTM
,but the namegetScreenCTM
is kept for historical reasons.
InterfaceSVGGeometryElement represents SVG elements whose renderingis defined by geometry with anequivalent path,and which can be filled and stroked.This includes paths and the basic shapes.
[Exposed=Window]interfaceSVGGeometryElement :SVGGraphicsElement { [SameObject] readonly attributeSVGAnimatedNumberpathLength; boolean isPointInFill(optionalDOMPointInit point); boolean isPointInStroke(optionalDOMPointInit point); floatgetTotalLength();DOMPointgetPointAtLength(float distance);};
TheisPointInFill method,when invoked, must return true if the point given bypoint passed to the method,in the coordinate space of an element, is inside the intended path as determined by the windingrule indicated by thefill-rule property of an element; and must return false otherwise.Open subpaths must be implicitly closed when computing the area inside the path, without affectingthe actual subpaths. Points on the path itself must be considered to be inside the path.The returned value is independent of any visual CSS property butfill-ruleIf either of thex ory properties onpoint are infinite or NaN,then the method must return false.
isPointInFill takes the windingrule indicated by thefill-rule property of an element even if the element is a childof a‘clipPath’ element.
isPointInFill is alignedwith theisPointInPath method on theCanvasDrawPath mixin as much as the SVG contextallows it to be.
TheisPointInStroke method,when invoked, must return true if the point given bypoint passed to the method,in the coordinate space of an element, is in or on the outline path of an applied stroke onan element; and must return false otherwise.The outline path must take the stroke propertiesstroke-width,stroke-linecap,stroke-linejoin,stroke-miterlimit,stroke-dasharrayandstroke-dashoffset of an element into account.The returned value is independent of any visual CSS property but the listed stroke properties.If either of thex ory properties onpoint are infinite or NaN,then the method must return false.
isPointInStroke is alignedwith theisPointInPath method on theCanvasDrawPath mixin as much as the SVGcontextallows it to be.
ThepathLength IDL attributereflects the‘pathLength’ content attribute.
ThegetTotalLength methodis used to compute the length of the path. When getTotalLength()is called, the user agent's computed value for the total length of the path,in user units, is returned.
The user agent's computed path length does not take the‘pathLength’ attribute into account.
ThegetPointAtLength methodis used to return the point at a given distance along the path. WhengetPointAtLength(distance) is called, the following steps are run:
As withgetTotalLength, this does not take into account the‘pathLength’ attribute.
TheSVGNumber interface is used primarily to represent a<number>value that is a part of anSVGNumberList. IndividualSVGNumberobjects can also be created by script.
AnSVGNumber object can be designated asread only,which means that attempts to modify the object will result in an exceptionbeing thrown, as described below.SVGNumber objects reflected through the animVal IDL attribute are alwaysread only.
AnSVGNumber object can beassociatedwith a particular element. The associated element is used todetermine which element's content attribute to update if the objectreflectsan attribute. Unless otherwise described, anSVGNumber object is notassociated with any element.
EverySVGNumber object operates in one of twomodes. It can:
AnSVGNumber object maintains an internal number value,which is called itsvalue.
[Exposed=Window]interfaceSVGNumber { attribute floatvalue;};
Thevalue IDL attributerepresents the number. On gettingvalue,theSVGNumber'svalue is returned.
On settingvalue, the followingsteps are run:
TheSVGLength interface is used to represent a value thatcan be a<length>,<percentage> or<number> value.
AnSVGLength object can be designated asread only,which means that attempts to modify the object will result in an exceptionbeing thrown, as described below.SVGLength objects reflected through the animVal IDL attribute are alwaysread only.
AnSVGLength object can beassociatedwith a particular element, as well as being designated with adirectionality:horizontal, vertical or unspecified. The associated element and the directionality of thelength are used to resolve percentage values to user units and is also used todetermine which element's content attribute to update if the objectreflectsan attribute. Unless otherwisedescribed, anSVGLength object is not associated with any element andhas unspecified directionality.
EverySVGLength object operates in one offour modes. It can:
AnSVGLength object maintains an internal<length> or<percentage> or<number> value, which is called itsvalue.
[Exposed=Window]interfaceSVGLength { // Length Unit Types const unsigned shortSVG_LENGTHTYPE_UNKNOWN = 0; const unsigned shortSVG_LENGTHTYPE_NUMBER = 1; const unsigned shortSVG_LENGTHTYPE_PERCENTAGE = 2; const unsigned shortSVG_LENGTHTYPE_EMS = 3; const unsigned shortSVG_LENGTHTYPE_EXS = 4; const unsigned shortSVG_LENGTHTYPE_PX = 5; const unsigned shortSVG_LENGTHTYPE_CM = 6; const unsigned shortSVG_LENGTHTYPE_MM = 7; const unsigned shortSVG_LENGTHTYPE_IN = 8; const unsigned shortSVG_LENGTHTYPE_PT = 9; const unsigned shortSVG_LENGTHTYPE_PC = 10; readonly attribute unsigned shortunitType; attribute floatvalue; attribute floatvalueInSpecifiedUnits; attribute DOMStringvalueAsString; voidnewValueSpecifiedUnits(unsigned short unitType, float valueInSpecifiedUnits); voidconvertToSpecifiedUnits(unsigned short unitType);};
The numeric length unit type constants defined onSVGLength are usedto represent the type of anSVGLength'svalue.Their meanings are as follows:
Constant | Meaning |
---|---|
SVG_LENGTHTYPE_NUMBER | A unitless<number> interpreted as a value inpx. |
SVG_LENGTHTYPE_PERCENTAGE | A<percentage>. |
SVG_LENGTHTYPE_EMS | A<length> with anem unit. |
SVG_LENGTHTYPE_EXS | A<length> with anex unit. |
SVG_LENGTHTYPE_PX | A<length> with apx unit. |
SVG_LENGTHTYPE_CM | A<length> with acm unit. |
SVG_LENGTHTYPE_MM | A<length> with amm unit. |
SVG_LENGTHTYPE_IN | A<length> with anin unit. |
SVG_LENGTHTYPE_PT | A<length> with apt unit. |
SVG_LENGTHTYPE_PC | A<length> with apc unit. |
SVG_LENGTHTYPE_UNKNOWN | Some other type of value. |
The use of numeric length unit type constants is an anti-pattern andnew constant values will not be introduced for any other units or length types supported bySVGLength. If other types of lengths are supported and used, theSVGLengthuses theSVG_LENGTHTYPE_UNKNOWNunit type. See below for details on how the other properties of anSVGLengthoperate with these types of lengths.
TheunitType IDL attribute representsthe type of value that theSVGLength'svalue is.On gettingunitType, the following stepsare run:
For example, for a<length> with ach unit or one that has a non-scalar value such ascalc(),SVG_LENGTHTYPE_UNKNOWN would be returned.
Thevalue IDL attribute representstheSVGLength'svalue in user units.On gettingvalue, the following stepsare run:
On settingvalue, the following stepsare run:
ThevalueInSpecifiedUnits IDL attribute representsthe numeric factor of theSVGLength'svalue.On gettingvalueInSpecifiedUnits, the following stepsare run:
ThusvalueInSpecifiedUnits would return 12 for both'12%' and12em, but 0 would be returned for non-scalar values likecalc(12px + 5%).
On settingvalueInSpecifiedUnits, the following stepsare run:
ThevalueAsString IDL attribute representstheSVGLength'svalue as a string.On gettingvalueAsString, the following stepsare run:
On settingvalueAsString, the following stepsare run:
ThenewValueSpecifiedUnitsmethod is used to set theSVGLength's value in a typed manner. WhennewValueSpecifiedUnits(unitType, valueInSpecifiedUnits) is called, the followingsteps are run:
TheconvertToSpecifiedUnitsmethod is used to convert theSVGLength's value to a specific type.When convertToSpecifiedUnits(unitType) is called, the following steps are run:
TheSVGAngle interface is used to represent a value thatcan be an<angle> or<number> value.
AnSVGAngle object can be designated asread only,which means that attempts to modify the object will result in an exceptionbeing thrown, as described below. AnSVGAngle reflected through theanimVal attribute is alwaysread only.
AnSVGAngle object can beassociatedwith a particular element. The associated element is used todetermine which element's content attribute to update if the objectreflectsan attribute. Unless otherwise described, anSVGAngle object is notassociated with any element.
EverySVGAngle object operates in one oftwo modes. It can:
AnSVGAngle object maintains an internal<angle> or<number> value, which is called itsvalue.
[Exposed=Window]interfaceSVGAngle { // Angle Unit Types const unsigned shortSVG_ANGLETYPE_UNKNOWN = 0; const unsigned shortSVG_ANGLETYPE_UNSPECIFIED = 1; const unsigned shortSVG_ANGLETYPE_DEG = 2; const unsigned shortSVG_ANGLETYPE_RAD = 3; const unsigned shortSVG_ANGLETYPE_GRAD = 4; readonly attribute unsigned shortunitType; attribute floatvalue; attribute floatvalueInSpecifiedUnits; attribute DOMStringvalueAsString; voidnewValueSpecifiedUnits(unsigned short unitType, float valueInSpecifiedUnits); voidconvertToSpecifiedUnits(unsigned short unitType);};
The numeric angle unit type constants defined onSVGAngle are usedto represent the type of anSVGAngle'svalue.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 adeg unit. |
SVG_ANGLETYPE_RAD | An<angle> with arad unit. |
SVG_ANGLETYPE_GRAD | An<angle> with agrad unit. |
SVG_ANGLETYPE_UNKNOWN | Some other type of value. |
The use of numeric angle unit type constants is an anti-pattern andnew constant values will not be introduced for any other units or angle types supported bySVGAngle. If other types of angles are supported and used, theSVGAngleuses theSVG_ANGLETYPE_UNKNOWNunit type. See below for details on how the other properties of anSVGAngleoperate with these types of angles.
TheunitType IDL attribute representsthe type of value that theSVGAngle'svalue is.On gettingunitType, the following stepsare run:
For example, for an<angle> with aturn unit,SVG_ANGLETYPE_UNKNOWN would be returned.
Thevalue IDL attribute representstheSVGAngle'svalue in degrees.On gettingvalue, the following stepsare run:
On settingvalue, the following stepsare run:
ThevalueInSpecifiedUnits IDL attribute representsthe numeric factor of theSVGAngle'svalue.On gettingvalueInSpecifiedUnits, the following stepsare run:
On settingvalueInSpecifiedUnits, the following stepsare run:
ThevalueAsString IDL attribute representstheSVGAngle'svalue as a string.On gettingvalueAsString, the following stepsare run:
On settingvalueAsString, the following stepsare run:
ThenewValueSpecifiedUnitsmethod is used to set theSVGAngle's value in a typed manner. WhennewValueSpecifiedUnits(unitType, valueInSpecifiedUnits) is called, the followingsteps are run:
TheconvertToSpecifiedUnitsmethod is used to convert theSVGAngle's value to a specific type.When convertToSpecifiedUnits(unitType) is called, the following steps are run:
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) |
Status: | Done |
Some SVG attributes contain lists of values, and to represent these valuesthere are a number of SVG DOMlist interfaces, onefor each required element type –SVGNumberList,SVGLengthList,SVGPointList,SVGTransformList andSVGStringList.The first four are used to represent the base andanimated components ofSVGAnimatedNumberList,SVGAnimatedLengthList,SVGAnimatedPoints andSVGTransformList objects,while the fifth,SVGStringList, is used toreflect afew unanimated attributes that take a list of strings.
Mostlist interfaces take the following form:
interfaceSVGNameList { readonly attribute unsigned longlength; readonly attribute unsigned longnumberOfItems; voidclear();Typeinitialize(Type newItem); getterTypegetItem(unsigned long index);TypeinsertItemBefore(Type newItem, unsigned long index);TypereplaceItem(Type newItem, unsigned long index);TyperemoveItem(unsigned long index);TypeappendItem(Type newItem);setter void (unsigned long index,Type newItem);};
whereName is a descriptive name for the list element's("Number", "Length", "Point", "Transform" or "String") andType is the IDL type of thelist's elements (SVGNumber,SVGLength,DOMPoint,SVGTransform orDOMString).
TheSVGTransformList interface takes the above form but hastwo additional methods on it.
Alllist interface objects apart fromSVGTransformListreflect the base value of a reflected contentattribute.SVGTransformList objects reflect a presentationattribute (‘transform’,‘gradientTransform’ or‘patternTransform’).Alllist interface objects are associated with a particular element.UnlikeSVGLength and similar objects, there are no "detached"list interface objects.
Alist 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 elementsof the list. The list can also be changed in response tochanges to the reflected content attribute and to animation ofthe content attribute (or, forSVGTransformList objects,in response to changes to the computed value of thetransformproperty).
Alist interface object can be designated asread only, which means that attempts to modify the object will resultin an exception being thrown, as described below.list interface objectsreflected through the animVal IDL attribute are alwaysread only.
Alist interface objectissynchronized by runningthe following steps:
Whenever a list element object is to bedetached,the following steps are run, depending on the list element type:
Whenever a list element object is to beattached,the following steps are run, depending on the list element type:
Thesupported property indicesof alist interface object is the set of all non-negative integersless than the length of the list.
Thelength andnumberOfItems IDL attributesrepresents the length of the list, and on getting simply returnthe length of the list.
Theclear method is used toremove all items in the list. When clear() is called, the following steps are run:
Theinitialize methodis used to clear the list and add a single, specified value to it.When initialize(newItem) is called, the following steps are run:
ThegetItem method is usedto get an item from the list at the specified position. WhengetItem(index) is called, the following steps are run:
Note that if the list's element type is an object type, such asSVGLength, then a reference to that object and not a copy of it is returned.
TheinsertItemBeforemethod is used to insert an element into the list at a specific position.When insertItemBefore(newItem,index) is called,the following steps are run:
ThereplaceItem methodis used to replace an existing item in the list with a new item.When replaceItem(newItem,index) is called, thefollowing steps are run:
TheremoveItem methodis used to remove an item from the list. When removeItem(index)is called, the following steps are run:
TheappendItem methodis used to append an item to the end of the list. When appendItem(newItem)is called, the following steps are run:
The behavior of theindexed property setteris the same as that for thereplaceItemmethod.
TheSVGNumberList interface is alist interface whoseelements areSVGNumber objects. AnSVGNumberList objectrepresents a list of numbers.
[Exposed=Window]interfaceSVGNumberList { readonly attribute unsigned longlength; readonly attribute unsigned longnumberOfItems; voidclear();SVGNumberinitialize(SVGNumber newItem); getterSVGNumbergetItem(unsigned long index);SVGNumberinsertItemBefore(SVGNumber newItem, unsigned long index);SVGNumberreplaceItem(SVGNumber newItem, unsigned long index);SVGNumberremoveItem(unsigned long index);SVGNumberappendItem(SVGNumber newItem);setter void (unsigned long index,SVGNumber newItem);};
The behavior of all of the interface members ofSVGNumberList aredefined in theList interfaces section above.
TheSVGLengthList interface is alist interface whoseelements areSVGLength objects. AnSVGLengthList objectrepresents a list of lengths.
[Exposed=Window]interfaceSVGLengthList { readonly attribute unsigned longlength; readonly attribute unsigned longnumberOfItems; voidclear();SVGLengthinitialize(SVGLength newItem); getterSVGLengthgetItem(unsigned long index);SVGLengthinsertItemBefore(SVGLength newItem, unsigned long index);SVGLengthreplaceItem(SVGLength newItem, unsigned long index);SVGLengthremoveItem(unsigned long index);SVGLengthappendItem(SVGLength newItem);setter void (unsigned long index,SVGLength newItem);};
The behavior of all of the interface members ofSVGLengthList aredefined in theList interfaces section above.
TheSVGStringList interface is alist interface whoseelements areDOMString values. AnSVGStringList objectrepresents a list of strings.
[Exposed=Window]interfaceSVGStringList { readonly attribute unsigned longlength; readonly attribute unsigned longnumberOfItems; voidclear(); DOMStringinitialize(DOMString newItem); getter DOMStringgetItem(unsigned long index); DOMStringinsertItemBefore(DOMString newItem, unsigned long index); DOMStringreplaceItem(DOMString newItem, unsigned long index); DOMStringremoveItem(unsigned long index); DOMStringappendItem(DOMString newItem);setter void (unsigned long index, DOMString newItem);};
The behavior of all of the interface members ofSVGStringList aredefined in theList interfaces section above.
The following interfaces are used to represent the reflected value of animatable content attributes. They each consist of two component objects, representing the same data:baseVal
andanimVal
. ThebaseVal
(base value) object is modifiable, to update the corresponding attribute value.
In SVG 1.1, theanimVal
attribute of the SVG DOM interfaces represented the current animated value of the reflected attribute. In this version of SVG,animVal
no longer representes the current animated value and is instead an alias ofbaseVal
.
AnSVGAnimatedBoolean object is used toreflect ananimatable attribute that takes a boolean value.
[Exposed=Window]interfaceSVGAnimatedBoolean { attribute booleanbaseVal; readonly attribute booleananimVal;};
ThebaseVal andanimVal IDL attributesboth represent the current non-animated value of the reflected attribute.On gettingbaseValoranimVal,the following steps are run:
On settingbaseVal,the reflected attribute is set to "true" if the value is true, and "false"otherwise.
AnSVGAnimatedEnumeration object is used toreflectan animatable attribute that takes a keyword value (such asthe‘method’ attribute on‘textPath’) or to reflectthe type of value that an animatable attribute has (doneonly by theorientTypeIDL attribute for the‘marker’ element's‘orient’ attribute).
[Exposed=Window]interfaceSVGAnimatedEnumeration { attribute unsigned shortbaseVal; readonly attribute unsigned shortanimVal;};
ForSVGAnimatedEnumeration objects thatreflect ananimatable attribute that takes only a keyword value, thebaseVal andanimVal IDL attributesrepresents the current non-animated value of the reflected attribute.FororientType,they represent the type of the current non-animated value of thereflected‘orient’ attribute. On gettingbaseVal oranimVal, thefollowing steps are run:
On settingbaseVal,the following steps are run:
AnSVGAnimatedInteger object is used toreflect ananimatable attribute that takes an integer value (such as‘numOctaves’ on‘feTurbulence’). It is alsoused to reflect one part of an animatable attribute that takesan integer followed by an optional second integer (such as‘order’ on‘feConvolveMatrix’).
ThisSVGAnimatedInteger interfaceis not used in this specification, however theFilter Effectsspecification has a number of uses of it.
[Exposed=Window]interfaceSVGAnimatedInteger { attribute longbaseVal; readonly attribute longanimVal;};
ForSVGAnimatedInteger objects thatreflectan animatable attribute that takes a single integer value, thebaseVal andanimVal IDL attributesrepresent the current non-animated value of the reflected attribute.For those that reflect one integer of an attribute that takes aninteger followed by an optional second integer, they represent thecurrent non-animated value of one of the two integers. On gettingbaseVal oranimVal, thefollowing steps are run:
For example, the definition of‘order’ says that the implicit second integer is the same as the explicit first integer.
On settingbaseVal,the following steps are run:
AnSVGAnimatedNumber object is used toreflect ananimatable attribute that takes a number value (such as‘pathLength’ on‘path’). It is alsoused to reflect one part of an animatable attribute that takesan number followed by an optional second number (such as‘kernelUnitLength’ on‘feDiffuseLighting’).
[Exposed=Window]interfaceSVGAnimatedNumber { attribute floatbaseVal; readonly attribute floatanimVal;};
ForSVGAnimatedNumber objects thatreflectan animatable attribute that takes a single number value, thebaseVal andanimVal IDL attributesrepresent the current non-animated value of the reflected attribute.For those that reflect one number of an attribute that takes anumber followed by an optional second number, they represent thecurrent non-animated value of one of the two numbers. On gettingbaseVal oranimVal, thefollowing steps are run:
For example, the definition of‘kernelUnitLength’ says that the implicit second number is the same as the explicit first number.
On settingbaseVal,the following steps are run:
AnSVGAnimatedLength object is used toreflect either(a) an animatable attribute that takes a<length>,<percentage> or<number> value, or (b) aCSS property that takes one of these values and its correspondingpresentation attribute.
[Exposed=Window]interfaceSVGAnimatedLength { [SameObject] readonly attributeSVGLengthbaseVal; [SameObject] readonly attributeSVGLengthanimVal;};
ThebaseVal andanimVal IDL attributesrepresent the current value of the reflected content attribute.On gettingbaseVal oranimVal,anSVGLength object is returned that:
AnSVGAnimatedAngle object is used toreflectthe<angle> value of the animated‘orient’attribute on‘marker’, through theorientAngleIDL attribute.
[Exposed=Window]interfaceSVGAnimatedAngle { [SameObject] readonly attributeSVGAnglebaseVal; [SameObject] readonly attributeSVGAngleanimVal;};
ThebaseVal andanimVal IDL attributes representthe current non-animated<angle> value of thereflected‘orient’ attribute. On gettingbaseVal oranimVal, anSVGAngle object is returned that:
AnSVGAnimatedString object is used toreflect ananimatable attribute that takes a string value. It can optionallybe defined to additionally reflect a second, deprecated attribute.
[Exposed=Window]interfaceSVGAnimatedString { attribute DOMStringbaseVal; readonly attribute DOMStringanimVal;};
ThebaseValandanimVal IDL attributesrepresent the current non-animated value of the reflected attribute.On gettingbaseValoranimVal,the following steps are run:
For thehrefmember on theSVGURIReference interface, this will result inthe deprecated‘xlink:href’ attribute being returned if it ispresent and the‘href’ attribute is not,and in the‘href’ attribute beingreturned in all other cases.
On settingbaseVal,the following steps are run:
For thehrefmember on theSVGURIReference interface, this will result inthe deprecated‘xlink:href’ attribute being set if it ispresent and the‘href’ attribute is not,and in the‘href’ attribute beingset in all other cases.
AnSVGAnimatedRect object is used toreflect ananimatable attribute that takes a rectangle value as specifiedby anx,y,width andheight.
In this specification the only attribute to bereflected as anSVGAnimatedRect is‘viewBox’.
[Exposed=Window]interfaceSVGAnimatedRect { [SameObject] readonly attributeDOMRectbaseVal; [SameObject] readonly attributeDOMRectReadOnlyanimVal;};
ThebaseValandanimVal IDLattributes represent the current non-animated rectangle value ofthe reflected attribute. On gettingbaseValoranimVal,aDOMRect object is returned.
Upon creation of thebaseValoranimValDOMRect objects, and afterwards whenever the reflected content attributeis added, removed, or changed, the following steps are run:
Whenever thex coordinate,y coordinate,width orheight propertyof thebaseVal oranimValDOMRect object changes, except as part of the previous algorithm thatreflects the value of the content attribute into theDOMRect, the reflectedcontent attribute must bereserialized.
AnSVGAnimatedNumberList object is used toreflect an animatableattribute that takes a list of<number> values.
[Exposed=Window]interfaceSVGAnimatedNumberList { [SameObject] readonly attributeSVGNumberListbaseVal; [SameObject] readonly attributeSVGNumberListanimVal;};
ThebaseValandanimVal IDL attributesrepresent the current non-animated value of the reflected attribute.On gettingbaseVal oranimVal,anSVGNumberList object is returned that reflects the base valueof the reflected attribute.
AnSVGAnimatedLengthList object is used toreflect an animatableattribute that takes a list of<length>,<percentage>or<number> values.
[Exposed=Window]interfaceSVGAnimatedLengthList { [SameObject] readonly attributeSVGLengthListbaseVal; [SameObject] readonly attributeSVGLengthListanimVal;};
ThebaseValoranimVal IDL attributesrepresent the current non-animated value of the reflected attribute.On gettingbaseVal oranimVal,anSVGLengthList object is returned that reflects the base valueof the reflected attribute.
TheSVGUnitTypes interface defines a commonly used set of constantsused for reflecting‘gradientUnits’,‘patternContentUnits’ andother similar attributes.
[Exposed=Window]interfaceSVGUnitTypes { // Unit Types const unsigned shortSVG_UNIT_TYPE_UNKNOWN = 0; const unsigned shortSVG_UNIT_TYPE_USERSPACEONUSE = 1; const unsigned shortSVG_UNIT_TYPE_OBJECTBOUNDINGBOX = 2;};
The unit type constants defined onSVGUnitTypes 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. |
TheSVGTests interface is used to reflectconditional processing attributes, and is mixed in to otherinterfaces for elements that support these attributes.
interface mixinSVGTests { [SameObject] readonly attributeSVGStringListrequiredExtensions; [SameObject] readonly attributeSVGStringListsystemLanguage;};
TherequiredExtensions IDL attributereflects the‘requiredExtensions’ content attribute.
ThesystemLanguage IDL attributereflects the‘systemLanguage’ content attribute.
TheSVGFitToViewBox interface is used to reflectthe‘viewBox’ and‘preserveAspectRatio’ attributes,and is mixed in to other interfaces for elements that supportthese two attributes.
interface mixinSVGFitToViewBox { [SameObject] readonly attributeSVGAnimatedRectviewBox; [SameObject] readonly attributeSVGAnimatedPreserveAspectRatiopreserveAspectRatio;};
TheviewBox IDL attributereflects the‘viewBox’ content attribute.
ThepreserveAspectRatio IDL attributereflects the‘preserveAspectRatio’ content attribute.
TheSVGZoomAndPan interface is used to reflect the‘zoomAndPan’ attribute, and is mixed in to otherinterfaces for elements that support this attribute.
interface mixinSVGZoomAndPan { // Zoom and Pan Types const unsigned shortSVG_ZOOMANDPAN_UNKNOWN = 0; const unsigned shortSVG_ZOOMANDPAN_DISABLE = 1; const unsigned shortSVG_ZOOMANDPAN_MAGNIFY = 2; attribute unsigned shortzoomAndPan;};
The zoom and pan type constants defined onSVGZoomAndPan have thefollowing 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. |
ThezoomAndPanIDL attribute represents the value of the‘zoomAndPan’ attribute.On gettingzoomAndPan, thefollowing steps are run:
On settingzoomAndPan,the following steps are run:
TheSVGURIReference interface is used to reflectthe‘href’ attribute and the deprecated‘xlink:href’ attribute.
interface mixinSVGURIReference { [SameObject] readonly attributeSVGAnimatedStringhref;};
Thehref IDL attributerepresents the value of the‘href’attribute, and, on elements that are defined to support it,the deprecated‘xlink:href’ attribute. On gettinghref, anSVGAnimatedString object is returned that:
TheSVGAnimatedString interface is definedto reflect, through itsbaseValandanimVal members, the deprecated‘xlink:href’ attribute, if that attribute ispresent and the‘href’ is not, and toreflect the‘href’ attribute in allother circumstances.Animation elementstreatattributeName='xlink:href'as being an alias for targetting the‘href’ attribute.