@@ -66,8 +66,6 @@ class Interface {
6666 this . ctx = ctx ;
6767 this . idl = idl ;
6868 this . name = idl . name ;
69- this . sharedConstructorName = `Shared${ this . name } ` ;
70-
7169 for ( const member of this . idl . members ) {
7270 member . definingInterface = this . name ;
7371 }
@@ -1407,15 +1405,15 @@ class Interface {
14071405 }
14081406
14091407 generateInstall ( ) {
1410- const { idl, name, sharedConstructorName } = this ;
1408+ const { idl, name } = this ;
14111409
14121410 this . str += `
14131411 install(globalObject) {
14141412 ` ;
14151413
14161414 const ctor = this . getConstructor ( ) ;
14171415 this . str += `
1418- const ${ name } = function(${ formatArgs ( ctor . argNames ) } ) {
1416+ const ctor = function ${ name } (${ formatArgs ( ctor . argNames ) } ) {
14191417 ${ ctor . body }
14201418 };
14211419 ` ;
@@ -1426,7 +1424,7 @@ class Interface {
14261424 ] ;
14271425 if ( staticPropertyNames . length ) {
14281426 this . str += `
1429- Object.defineProperties(${ name } , {
1427+ Object.defineProperties(ctor , {
14301428 ` ;
14311429
14321430 for ( const staticProperty of staticPropertyNames ) {
@@ -1436,7 +1434,7 @@ class Interface {
14361434 propertyKey . replace ( "[" , "" ) . replace ( "]" , "" ) :
14371435 `"${ propertyKey } "` ;
14381436
1439- this . str += `${ propertyKey } : Object.getOwnPropertyDescriptor(${ sharedConstructorName } , ${ propertyValue } ),\n` ;
1437+ this . str += `${ propertyKey } : Object.getOwnPropertyDescriptor(${ name } , ${ propertyValue } ),\n` ;
14401438 }
14411439
14421440 this . str += `
@@ -1464,14 +1462,14 @@ class Interface {
14641462 // newly created constructor.
14651463 this . str += `
14661464 Object.defineProperties(proto, {
1467- ...Object.getOwnPropertyDescriptors(${ sharedConstructorName } .prototype),
1465+ ...Object.getOwnPropertyDescriptors(${ name } .prototype),
14681466 constructor: {
14691467 writable: true,
14701468 configurable: true,
1471- value: ${ name }
1469+ value: ctor
14721470 }
14731471 });
1474- Object.defineProperty(${ name } , "prototype", {
1472+ Object.defineProperty(ctor , "prototype", {
14751473 writable: false,
14761474 value: proto
14771475 });
@@ -1483,12 +1481,12 @@ class Interface {
14831481 if (globalObject[ctorRegistry] === undefined) {
14841482 globalObject[ctorRegistry] = {};
14851483 }
1486- globalObject[ctorRegistry]["${ name } "] = ${ name } ;
1484+ globalObject[ctorRegistry]["${ name } "] = ctor ;
14871485
14881486 Object.defineProperty(globalObject, "${ name } ", {
14891487 configurable: true,
14901488 writable: true,
1491- value: ${ name }
1489+ value: ctor
14921490 });
14931491 },
14941492 ` ;
@@ -1497,7 +1495,7 @@ class Interface {
14971495 generate ( ) {
14981496 this . generateIterator ( ) ;
14991497
1500- this . str += `class ${ this . sharedConstructorName } {` ;
1498+ this . str += `class ${ this . name } {` ;
15011499
15021500 this . generateOffInstanceMethods ( ) ;
15031501
0 commit comments