@@ -23,23 +23,15 @@ class Attribute {
23
23
24
24
const onInstance = utils . isOnInstance ( this . idl , this . interface . idl ) ;
25
25
26
- let objName = `this` ;
27
- if ( onInstance ) { // we're in a setup method
28
- objName = `obj` ;
29
- }
30
- let brandCheck = this . interface . isGlobal ? `
31
- if (this !== null && this !== undefined && !exports.is(this)) {
32
- throw new TypeError("Illegal invocation");
33
- }
34
- ` : `
35
- if (!this || !exports.is(this)) {
26
+ let brandCheck = `
27
+ if (!exports.is(esValue)) {
36
28
throw new TypeError("Illegal invocation");
37
29
}
38
30
` ;
39
- let getterBody = `return utils.tryWrapperForImpl(${ objName } [impl]["${ this . idl . name } "]);` ;
40
- let setterBody = `${ objName } [impl]["${ this . idl . name } "] = V;` ;
31
+ let getterBody = `return utils.tryWrapperForImpl(esValue [impl]["${ this . idl . name } "]);` ;
32
+ let setterBody = `esValue [impl]["${ this . idl . name } "] = V;` ;
41
33
if ( conversions [ this . idl . idlType . idlType ] ) {
42
- getterBody = `return ${ objName } [impl]["${ this . idl . name } "];` ;
34
+ getterBody = `return esValue [impl]["${ this . idl . name } "];` ;
43
35
}
44
36
45
37
const addMethod = this . static ?
@@ -55,8 +47,8 @@ class Attribute {
55
47
throw new Error ( "Unknown reflector type: " + this . idl . idlType . idlType ) ;
56
48
}
57
49
const attrName = shouldReflect . rhs && shouldReflect . rhs . value . replace ( / _ / g, "-" ) || this . idl . name ;
58
- getterBody = reflector [ this . idl . idlType . idlType ] . get ( objName , attrName . toLowerCase ( ) ) ;
59
- setterBody = reflector [ this . idl . idlType . idlType ] . set ( objName , attrName . toLowerCase ( ) ) ;
50
+ getterBody = reflector [ this . idl . idlType . idlType ] . get ( "esValue" , attrName . toLowerCase ( ) ) ;
51
+ setterBody = reflector [ this . idl . idlType . idlType ] . set ( "esValue" , attrName . toLowerCase ( ) ) ;
60
52
}
61
53
62
54
if ( utils . getExtAttr ( this . idl . extAttrs , "LenientThis" ) ) {
@@ -75,6 +67,7 @@ class Attribute {
75
67
}
76
68
77
69
addMethod ( this . idl . name , [ ] , `
70
+ const esValue = this !== null && this !== undefined ? this : globalObject;
78
71
${ brandCheck }
79
72
${ getterBody }
80
73
` , "get" , { configurable } ) ;
@@ -99,19 +92,22 @@ class Attribute {
99
92
}
100
93
101
94
addMethod ( this . idl . name , [ "V" ] , `
95
+ const esValue = this !== null && this !== undefined ? this : globalObject;
102
96
${ brandCheck }
103
97
${ idlConversion }
104
98
${ setterBody }
105
99
` , "set" , { configurable } ) ;
106
100
} else if ( utils . getExtAttr ( this . idl . extAttrs , "PutForwards" ) ) {
107
101
addMethod ( this . idl . name , [ "V" ] , `
102
+ const esValue = this !== null && this !== undefined ? this : globalObject;
108
103
${ brandCheck }
109
104
this.${ this . idl . name } .${ utils . getExtAttr ( this . idl . extAttrs , "PutForwards" ) . rhs . value } = V;
110
105
` , "set" , { configurable } ) ;
111
106
} else if ( utils . getExtAttr ( this . idl . extAttrs , "Replaceable" ) ) {
112
107
addMethod ( this . idl . name , [ "V" ] , `
108
+ const esValue = this !== null && this !== undefined ? this : globalObject;
113
109
${ brandCheck }
114
- Object.defineProperty(this , "${ this . idl . name } ", {
110
+ Object.defineProperty(esValue , "${ this . idl . name } ", {
115
111
configurable: true,
116
112
enumerable: true,
117
113
value: V,
0 commit comments