@@ -30,12 +30,12 @@ class CSSStyleDeclaration {
3030 * @param {object } globalObject - Window
3131 * @param {object } opt - Options
3232 * @param {object } opt.context - Element or CSSStyleRule
33+ * @param {string } opt.format - "specifiedValue" or "computedValue"
3334 * @param {Function } opt.onChange - Callback when cssText is changed or the property is removed
34- * @param {boolean } opt.computed - The computed flag
3535 * @param {boolean } opt.readOnly - The read-only flag
3636 */
3737 constructor ( globalObject = globalThis , opt = { } ) {
38- const { context } = opt ;
38+ const { context, format , onChange , readOnly , ... styleOpts } = opt ;
3939 this . _global = globalObject ;
4040 this . _ownerNode = null ;
4141 this . _parentRule = null ;
@@ -46,16 +46,20 @@ class CSSStyleDeclaration {
4646 this . _parentRule = context ;
4747 }
4848 }
49- this . _onChange = opt . onChange ;
50- this . _readonly = Boolean ( opt . readOnly ) ;
49+ this . _onChange = onChange ;
50+ this . _readonly = readOnly ?? false ;
5151 this . _computed = undefined ;
52- if ( opt . format === "computedValue" ) {
52+ const styleOptions = {
53+ ...styleOpts
54+ } ;
55+ if ( format === "computedValue" ) {
5356 this . _computed = true ;
54- } else {
57+ styleOptions . format = format ;
58+ } else if ( format !== "specifiedValue" ) {
5559 // Set the default format value.
56- opt . format = "specifiedValue" ;
60+ styleOptions . format = "specifiedValue" ;
5761 }
58- this . _options = opt ;
62+ this . _options = styleOptions ;
5963 this . _values = new Map ( ) ;
6064 this . _priorities = new Map ( ) ;
6165 this . _length = 0 ;
0 commit comments