@@ -1459,31 +1459,24 @@ export function emitWebIdl(
14591459 }
14601460
14611461 function emitIterator ( i : Browser . Interface ) {
1462- // check anonymous unsigned long getter and length property
1463- const isIterableGetter = ( m : Browser . AnonymousMethod ) =>
1462+ // https://heycam.github.io/webidl/#dfn-indexed- property-getter
1463+ const isIndexedPropertyGetter = ( m : Browser . AnonymousMethod ) =>
14641464 m . getter &&
14651465 m . signature [ 0 ] ?. param ?. length === 1 &&
14661466 typeof m . signature [ 0 ] . param [ 0 ] . type === "string" &&
14671467 integerTypes . has ( m . signature [ 0 ] . param [ 0 ] . type ) ;
14681468
14691469 function findIterableGetter ( ) {
1470- const anonymousGetter = i . anonymousMethods ?. method . find ( isIterableGetter ) ;
1470+ const anonymousGetter = i . anonymousMethods ?. method . find (
1471+ isIndexedPropertyGetter
1472+ ) ;
14711473
14721474 if ( anonymousGetter ) return anonymousGetter ;
14731475 else if ( i . methods )
1474- return mapToArray ( i . methods . method ) . find ( isIterableGetter ) ;
1476+ return mapToArray ( i . methods . method ) . find ( isIndexedPropertyGetter ) ;
14751477 else return undefined ;
14761478 }
14771479
1478- function hasLengthProperty ( i : Browser . Interface | undefined ) {
1479- const p = i ?. properties ?. property . length ;
1480- return (
1481- p ?. name === "length" &&
1482- typeof p . type === "string" &&
1483- integerTypes . has ( p . type )
1484- ) ;
1485- }
1486-
14871480 function getIteratorSubtypes ( ) {
14881481 if ( i . iterator ) {
14891482 if ( i . iterator . type . length === 1 ) {
@@ -1492,10 +1485,7 @@ export function emitWebIdl(
14921485 return i . iterator . type . map ( convertDomTypeToTsType ) ;
14931486 } else if ( i . name !== "Window" ) {
14941487 const iterableGetter = findIterableGetter ( ) ;
1495- const lengthProperty =
1496- hasLengthProperty ( i ) ||
1497- ( i . extends && hasLengthProperty ( allInterfacesMap [ i . extends ] ) ) ;
1498- if ( iterableGetter && lengthProperty ) {
1488+ if ( iterableGetter ) {
14991489 return [
15001490 convertDomTypeToTsType ( {
15011491 type : iterableGetter . signature [ 0 ] . type ,
0 commit comments