@@ -1277,11 +1277,7 @@ class Interface {
1277
1277
1278
1278
if ( _needsUnforgeablesObject ) {
1279
1279
this . str += `
1280
- const unforgeables = getUnforgeables(globalObject);
1281
- for (const key of Reflect.ownKeys(unforgeables)) {
1282
- const descriptor = Reflect.getOwnPropertyDescriptor(unforgeables, key);
1283
- Object.defineProperty(wrapper, key, descriptor);
1284
- }
1280
+ utils.define(wrapper, getUnforgeables(globalObject));
1285
1281
` ;
1286
1282
}
1287
1283
@@ -1572,10 +1568,9 @@ class Interface {
1572
1568
const propStrs = [ ...props ] . map ( ( [ name , body ] ) => `${ name } : ${ body } ` ) ;
1573
1569
if ( methods . length > 0 ) {
1574
1570
this . str += `
1575
- Object.defineProperties(
1576
- wrapper,
1577
- Object.getOwnPropertyDescriptors({ ${ methods . join ( ", " ) } })
1578
- );
1571
+ utils.define(wrapper, {
1572
+ ${ methods . join ( ", " ) }
1573
+ });
1579
1574
` ;
1580
1575
}
1581
1576
if ( propStrs . length > 0 ) {
@@ -1626,16 +1621,13 @@ class Interface {
1626
1621
function getUnforgeables(globalObject) {
1627
1622
let unforgeables = unforgeablesMap.get(globalObject);
1628
1623
if (unforgeables === undefined) {
1629
- unforgeables = Object.create(
1630
- null,
1624
+ unforgeables = Object.create(null);
1631
1625
` ;
1632
1626
1633
1627
if ( methods . length > 0 ) {
1634
- this . str += `Object.getOwnPropertyDescriptors( { ${ methods . join ( ", " ) } }), ` ;
1628
+ this . str += `utils.define(unforgeables, { ${ methods . join ( ", " ) } }); ` ;
1635
1629
}
1636
1630
1637
- this . str += ");" ;
1638
-
1639
1631
if ( props . size > 0 ) {
1640
1632
const propStrs = [ ...props ] . map ( ( [ name , body ] ) => `${ name } : ${ body } ` ) ;
1641
1633
this . str += `
0 commit comments