@@ -354,12 +354,9 @@ webidl.interfaceConverter = function (i) {
354354
355355webidl . dictionaryConverter = function ( converters ) {
356356 return ( dictionary , prefix , argument ) => {
357- const type = webidl . util . Type ( dictionary )
358357 const dict = { }
359358
360- if ( type === 'Null' || type === 'Undefined' ) {
361- return dict
362- } else if ( type !== 'Object' ) {
359+ if ( dictionary != null && webidl . util . Type ( dictionary ) !== 'Object' ) {
363360 throw webidl . errors . exception ( {
364361 header : prefix ,
365362 message : `Expected ${ dictionary } to be one of: Null, Undefined, Object.`
@@ -370,21 +367,21 @@ webidl.dictionaryConverter = function (converters) {
370367 const { key, defaultValue, required, converter } = options
371368
372369 if ( required === true ) {
373- if ( ! Object . hasOwn ( dictionary , key ) ) {
370+ if ( dictionary == null || ! Object . hasOwn ( dictionary , key ) ) {
374371 throw webidl . errors . exception ( {
375372 header : prefix ,
376373 message : `Missing required key "${ key } ".`
377374 } )
378375 }
379376 }
380377
381- let value = dictionary [ key ]
382- const hasDefault = Object . hasOwn ( options , ' defaultValue' )
378+ let value = dictionary ?. [ key ]
379+ const hasDefault = defaultValue !== undefined
383380
384381 // Only use defaultValue if value is undefined and
385382 // a defaultValue options was provided.
386- if ( hasDefault && value !== null ) {
387- value ?? = defaultValue ( )
383+ if ( hasDefault && value === undefined ) {
384+ value = defaultValue ( )
388385 }
389386
390387 // A key can be optional and have no default value.
0 commit comments