Closed cdoublev closed 2 years ago
getSameObject()
is only invoked for IDL attributes decorated with [SameObject]
, which, per IDL, always return the same object. It sounds like you want to not return the same object, so in that case, [SameObject]
is not appropriate.
Looking at the spec, it seems like the intent is to always return the same CSSRuleList
object, which is "live". So changing this._cssRules
is not a correct per-spec implementation, since that replaces the object itself; instead, you should modify the innards of this._cssRules
, so that the same object keeps being returned, just with different values.
Does that make sense?
Perfectly, thank you. I should have taken a look at its IDL signature. I would have seen [SameObject]
immediately. I wonder why Firefox seems to replace the object. Do you think it's worth filing an issue on Bugzilla?
Yeah, definitely. Although if Chrome and/or Safari also replace the object then maybe it's worth filing a spec bug.
In my implementation of
CSSStyleSheet.replaceSync()
, I have this:After running
styleSheet.replaceSync('div { color: green }')
,styleSheet.cssRules
still returns the old reference toCSSRuleList
, where eg.styleSheet.cssRules[0].style.color === 'red'
. I suspect that theProxy
forCSSStyleSheet.cssRules
returns a cached value because it can not detect thatthis._cssRules
has changed.Is it a bug or the expected behavior? Does a workaround exists?
Related: https://github.com/w3c/csswg-drafts/issues/6994
EDIT:
I confirm it works as I expect when commenting the following lines in
utils.js
(generated bywebidl2js
):I'm surprised because this would mean that the value returned by the getter implementation of a read-only property should be static, isn't it?