W3C home > Mailing lists > Public > www-dom@w3.org > July to September 2000

Re(2): Missing Exception for the setCssText method of the CSSValue interface.

From: Blaine Brodie <bbrodie@savagesoftware.com>
Date: Mon, 28 Aug 2000 17:31:11 -0700
Message-id: <fc.0085846d0000f9c20085846d00009427.fa0f@savagesoftware.com>
To: www-dom@w3.org
>> Hello Philippe,
>> Ok, I'd like to confirm my understanding of what you are saying with a
>> concrete
>> example.  In the current SVG spec there exists a CSS property called
>> 'stroke-dasharray'  (I'm quoting SVG because this is the only concrete
>> example I can
>> find.).  The representation for this property is either "ident or list
>of
>> lengths".  The syntax
>> for this property is 'none | <dasharray> | inherit'.
>> Assume I obtain this CSS value from the getPropertyCssValue() method...
>> 
>> value = style.getPropertyCssValue("stroke-dasharray");
>> value.getCssText();  //returns "none"
>> value.getValueType(); //returns CSS_PRIMITIVE_VALUE
>> CSSPrimitiveValue pValue = (CSSPrimitiveValue)value;
>> pValue.getPrimitiveType(); //returns CSS_IDENT
>> 
>> pValue.setCssText("5 3 2 5 3 2"); //Throws SYNTAX_ERR exception
>
>No, it doesn't return a SYNTAX_ERR since, according to the attached
>property, the syntax is correct.
>
>> However, if the above behavior is not correct and a SYNTAX_ERR exception
>> is not thrown
>> (ie the value type is changed), then can you please tell me which of the
>> following behavior
>> would be considered correct...
>> 
>> pValue.getCssText(); //returns "5 3 4 5 3 2"
>> pValue.getValueType(); //returns CSS_VALUE_LIST
>> pValue.getPrimitiveType(); //returns CSS_UNKNOWN
>
>The result of pValue.getPrimitiveType is undefined since it is no longer
>a primivite value. From a Java programmer point of view, it could
>throw a java.lang.IllegalStateException (for example). In ECMAScript, you
>might get an unknown property error. In any case, this is outside the
>scope of the specification.
>
Hello Phillippe,
To further clarify my understanding of how CSSPrimitiveValue is the
following behavior considered to be correct behavior?
Continuing from my previous example.

pValue.getCssText(); //returns "5 3 4 3 2"
pValue.getValueType(); //returns CSS_VALUE_LIST
pValue.setCssText("none");  //now pValue is back to a primitive type 
pValue.getPrimitiveType(); //no state exception is thrown since pValue 
			        //has been reverted to a primitive type.
			        //returns CSS_STRING

If this type of reversion capablity is considered correct behavior for
CSSValues, is it also considered to be correct behavior when using higher
level interfaces such as CSSStyleDeclaration.  For example is the
following possible? Assume I have a CSSStyleDeclaration named 'style'
style.setCssText("color: rgb(0, 0 ,0); font-size: 1.2em");
CSSValue value = style.getPropertyCssValue("color");
style.setCssText("margin: 0.5em");
// throws some sort of state exception ==>  value.getValueType();
//note the color and font-size switch
style.setCssText("font-size: 1.2em; color: rgb(0, 0 ,0) ");
value.getValueType(); //returns CSS_PRIMITIVE_VALUE
			 //where the primitive has type CSS_RGBCOLOR

Correct?  Thanks for the clarification.
---
Blaine
Received on Monday, 28 August 2000 20:31:16 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Friday, 22 June 2012 06:13:47 GMT