@@ -502,54 +502,54 @@ class Interface {
502
502
}
503
503
}
504
504
505
+ _supportsPropertyIndex ( O , index , indexedValue ) {
506
+ let unsupportedValue = utils . getExtAttr ( this . indexedGetter . extAttrs , "WebIDL2JSValueAsUnsupported" ) ;
507
+ if ( unsupportedValue ) {
508
+ unsupportedValue = unsupportedValue . rhs . value ;
509
+ }
510
+ if ( unsupportedValue ) {
511
+ const func = this . indexedGetter . name !== null ? `.${ this . indexedGetter . name } ` : "[utils.indexedGet]" ;
512
+ const value = indexedValue || `${ O } [impl]${ func } (${ index } )` ;
513
+ return `${ value } !== ${ unsupportedValue } ` ;
514
+ }
515
+ return `${ O } [impl][utils.supportsPropertyIndex](${ index } )` ;
516
+ }
517
+
518
+ _supportsPropertyName ( O , P , namedValue ) {
519
+ let unsupportedValue = utils . getExtAttr ( this . namedGetter . extAttrs , "WebIDL2JSValueAsUnsupported" ) ;
520
+ if ( unsupportedValue ) {
521
+ unsupportedValue = unsupportedValue . rhs . value ;
522
+ }
523
+ if ( unsupportedValue ) {
524
+ const func = this . namedGetter . name !== null ? `.${ this . namedGetter . name } ` : "[utils.namedGet]" ;
525
+ const value = namedValue || `${ O } [impl]${ func } (${ P } )` ;
526
+ return `${ value } !== ${ unsupportedValue } ` ;
527
+ }
528
+ return `${ O } [impl][utils.supportsPropertyName](${ P } )` ;
529
+ }
530
+
531
+ // "named property visibility algorithm"
532
+ // If `supports` is true then skip the supportsPropertyName check.
533
+ _namedPropertyVisible ( P , O , supports = false ) {
534
+ const conditions = [ ] ;
535
+ if ( ! supports ) {
536
+ conditions . push ( this . _supportsPropertyName ( O , P ) ) ;
537
+ }
538
+ if ( utils . getExtAttr ( this . idl . extAttrs , "OverrideBuiltins" ) ) {
539
+ conditions . push ( `!utils.hasOwn(${ O } , ${ P } )` ) ;
540
+ } else {
541
+ // TODO: create a named properties object.
542
+ conditions . push ( `!(${ P } in ${ O } )` ) ;
543
+ }
544
+ return conditions . join ( " && " ) ;
545
+ }
546
+
505
547
generateLegacyProxy ( ) {
506
548
const hasIndexedSetter = this . indexedSetter !== null ;
507
549
const hasNamedSetter = this . namedSetter !== null ;
508
550
const hasNamedDeleter = this . namedDeleter !== null ;
509
551
const overrideBuiltins = Boolean ( utils . getExtAttr ( this . idl . extAttrs , "OverrideBuiltins" ) ) ;
510
552
511
- const supportsPropertyIndex = ( O , index , indexedValue ) => {
512
- let unsupportedValue = utils . getExtAttr ( this . indexedGetter . extAttrs , "WebIDL2JSValueAsUnsupported" ) ;
513
- if ( unsupportedValue ) {
514
- unsupportedValue = unsupportedValue . rhs . value ;
515
- }
516
- if ( unsupportedValue ) {
517
- const func = this . indexedGetter . name !== null ? `.${ this . indexedGetter . name } ` : "[utils.indexedGet]" ;
518
- const value = indexedValue || `${ O } [impl]${ func } (${ index } )` ;
519
- return `${ value } !== ${ unsupportedValue } ` ;
520
- }
521
- return `${ O } [impl][utils.supportsPropertyIndex](${ index } )` ;
522
- } ;
523
-
524
- const supportsPropertyName = ( O , P , namedValue ) => {
525
- let unsupportedValue = utils . getExtAttr ( this . namedGetter . extAttrs , "WebIDL2JSValueAsUnsupported" ) ;
526
- if ( unsupportedValue ) {
527
- unsupportedValue = unsupportedValue . rhs . value ;
528
- }
529
- if ( unsupportedValue ) {
530
- const func = this . namedGetter . name !== null ? `.${ this . namedGetter . name } ` : "[utils.namedGet]" ;
531
- const value = namedValue || `${ O } [impl]${ func } (${ P } )` ;
532
- return `${ value } !== ${ unsupportedValue } ` ;
533
- }
534
- return `${ O } [impl][utils.supportsPropertyName](${ P } )` ;
535
- } ;
536
-
537
- // "named property visibility algorithm"
538
- // If `supports` is true then skip the supportsPropertyName check.
539
- function namedPropertyVisible ( P , O , supports = false ) {
540
- const conditions = [ ] ;
541
- if ( ! supports ) {
542
- conditions . push ( supportsPropertyName ( O , P ) ) ;
543
- }
544
- if ( overrideBuiltins ) {
545
- conditions . push ( `!utils.hasOwn(${ O } , ${ P } )` ) ;
546
- } else {
547
- // TODO: create a named properties object.
548
- conditions . push ( `!(${ P } in ${ O } )` ) ;
549
- }
550
- return conditions . join ( " && " ) ;
551
- }
552
-
553
553
// "invoke an indexed property setter"
554
554
const invokeIndexedSetter = ( O , P , V ) => {
555
555
const arg = this . indexedSetter . arguments [ 1 ] ;
@@ -566,7 +566,7 @@ class Interface {
566
566
567
567
if ( this . indexedSetter . name === null ) {
568
568
str += `
569
- const creating = !(${ supportsPropertyIndex ( O , "index" ) } );
569
+ const creating = !(${ this . _supportsPropertyIndex ( O , "index" ) } );
570
570
if (creating) {
571
571
${ O } [impl][utils.indexedSetNew](index, indexedValue);
572
572
} else {
@@ -597,7 +597,7 @@ class Interface {
597
597
598
598
if ( this . namedSetter . name === null ) {
599
599
str += `
600
- const creating = !(${ supportsPropertyName ( O , P ) } );
600
+ const creating = !(${ this . _supportsPropertyName ( O , P ) } );
601
601
if (creating) {
602
602
${ O } [impl][utils.namedSetNew](${ P } , namedValue);
603
603
} else {
@@ -677,7 +677,7 @@ class Interface {
677
677
if ( this . supportsNamedProperties ) {
678
678
this . str += `
679
679
for (const key of target[impl][utils.supportedPropertyNames]) {
680
- if (${ namedPropertyVisible ( "key" , "target" , true ) } ) {
680
+ if (${ this . _namedPropertyVisible ( "key" , "target" , true ) } ) {
681
681
keys.add(\`\${key}\`);
682
682
}
683
683
}
@@ -710,10 +710,10 @@ class Interface {
710
710
let condition ;
711
711
if ( utils . getExtAttr ( this . indexedGetter . extAttrs , "WebIDL2JSValueAsUnsupported" ) ) {
712
712
this . str += `const indexedValue = target[impl]${ func } (index);` ;
713
- condition = supportsPropertyIndex ( "target" , "index" , "indexedValue" ) ;
713
+ condition = this . _supportsPropertyIndex ( "target" , "index" , "indexedValue" ) ;
714
714
} else {
715
715
preamble = `const indexedValue = target[impl]${ func } (index);` ;
716
- condition = supportsPropertyIndex ( "target" , "index" ) ;
716
+ condition = this . _supportsPropertyIndex ( "target" , "index" ) ;
717
717
}
718
718
719
719
this . str += `
@@ -739,13 +739,13 @@ class Interface {
739
739
this . str += `
740
740
const namedValue = target[impl]${ func } (P);
741
741
` ;
742
- conditions . push ( supportsPropertyName ( "target" , "index" , "namedValue" ) ) ;
743
- conditions . push ( namedPropertyVisible ( "P" , "target" , true ) ) ;
742
+ conditions . push ( this . _supportsPropertyName ( "target" , "index" , "namedValue" ) ) ;
743
+ conditions . push ( this . _namedPropertyVisible ( "P" , "target" , true ) ) ;
744
744
} else {
745
745
preamble = `
746
746
const namedValue = target[impl]${ func } (P);
747
747
` ;
748
- conditions . push ( namedPropertyVisible ( "P" , "target" , false ) ) ;
748
+ conditions . push ( this . _namedPropertyVisible ( "P" , "target" , false ) ) ;
749
749
}
750
750
conditions . push ( "!ignoreNamedProps" ) ;
751
751
this . str += `
@@ -820,10 +820,10 @@ class Interface {
820
820
let condition ;
821
821
if ( utils . getExtAttr ( this . indexedGetter . extAttrs , "WebIDL2JSValueAsUnsupported" ) ) {
822
822
this . str += `const indexedValue = target[impl]${ func } (index);` ;
823
- condition = supportsPropertyIndex ( "target" , "index" , "indexedValue" ) ;
823
+ condition = this . _supportsPropertyIndex ( "target" , "index" , "indexedValue" ) ;
824
824
} else {
825
825
preamble = `const indexedValue = target[impl]${ func } (index);` ;
826
- condition = supportsPropertyIndex ( "target" , "index" ) ;
826
+ condition = this . _supportsPropertyIndex ( "target" , "index" ) ;
827
827
}
828
828
829
829
this . str += `
@@ -922,7 +922,7 @@ class Interface {
922
922
if ( ! hasNamedSetter ) {
923
923
needFallback = true ;
924
924
this . str += `
925
- const creating = !(${ supportsPropertyName ( "target" , "P" ) } );
925
+ const creating = !(${ this . _supportsPropertyName ( "target" , "P" ) } );
926
926
if (!creating) {
927
927
return false;
928
928
}
@@ -972,13 +972,13 @@ class Interface {
972
972
this . str += `
973
973
if (utils.isArrayIndexPropName(P)) {
974
974
const index = P >>> 0;
975
- return !(${ supportsPropertyIndex ( "target" , "index" ) } );
975
+ return !(${ this . _supportsPropertyIndex ( "target" , "index" ) } );
976
976
}
977
977
` ;
978
978
}
979
979
if ( this . supportsNamedProperties && ! utils . isGlobal ( this . idl ) ) {
980
980
this . str += `
981
- if (${ namedPropertyVisible ( "P" , "target" ) } ) {
981
+ if (${ this . _namedPropertyVisible ( "P" , "target" ) } ) {
982
982
` ;
983
983
if ( ! hasNamedDeleter ) {
984
984
this . str += `
0 commit comments