22
33const {
44 ArrayPrototypePush,
5- ArrayPrototypeSort ,
5+ ArrayPrototypeToSorted ,
66 MathAbs,
77 MathMax,
88 MathMin,
@@ -267,15 +267,9 @@ function type(V) {
267267// https://webidl.spec.whatwg.org/#js-dictionary
268268function createDictionaryConverter ( members ) {
269269 // The spec requires us to operate the members of a dictionary in
270- // lexicographical order. We are doing all of these in the outer scope to
270+ // lexicographical order. We are doing this in the outer scope to
271271 // reduce the overhead that could happen in the returned function.
272- const sortedMembers = [ ] ;
273- for ( let i = 0 ; i < members . length ; i ++ ) {
274- const member = members [ i ] ;
275- ArrayPrototypePush ( sortedMembers , member ) ;
276- }
277-
278- ArrayPrototypeSort ( sortedMembers , ( a , b ) => {
272+ const sortedMembers = ArrayPrototypeToSorted ( members , ( a , b ) => {
279273 if ( a . key === b . key ) {
280274 return 0 ;
281275 }
@@ -287,7 +281,7 @@ function createDictionaryConverter(members) {
287281 opts = kEmptyObject ,
288282 ) {
289283 const typeV = type ( V ) ;
290- if ( typeV !== 'Undefined' && typeV !== 'Null' && typeV !== 'Object' ) {
284+ if ( V !== undefined && V !== null && typeV !== 'Object' ) {
291285 throw makeException (
292286 'can not be converted to a dictionary' ,
293287 opts ,
@@ -299,7 +293,7 @@ function createDictionaryConverter(members) {
299293 const member = sortedMembers [ i ] ;
300294 const key = member . key ;
301295 let jsMemberValue ;
302- if ( typeV === 'Undefined' || typeV === 'Null' ) {
296+ if ( V == null ) {
303297 jsMemberValue = undefined ;
304298 } else {
305299 jsMemberValue = V [ key ] ;
0 commit comments