I'm not sure that the following behavior tested in Chrome and Firefox is described in any specification:
// Case 1: toString() from prototype
class Prop {
toString() {
return 1 // Number
}
}
style.setProperty('opacity', new Prop) // Ok, new value: 1
// Case 2: toString() from instance
const Prop = {
toString() {
return 1
}
}
style.setProperty('opacity', Prop) // Ok, new value: 1
// Case 3: recursive toString()
class RecursiveProp {
toString() {
return new Prop()
}
}
style.setProperty('opacity', new RecursiveProp) // Error
Ie. the value should be converted to String if it has a toString() method. cssstyle currently returns '' for all cases, ie. it results to an invalid value. Chrome and Firefox throw an error for case 3.
I'm not sure that the following behavior tested in Chrome and Firefox is described in any specification:
Ie. the value should be converted to String if it has a
toString()method.cssstylecurrently returns''for all cases, ie. it results to an invalid value. Chrome and Firefox throw an error for case 3.