.
<rdar://problem/91329468>
Created attachment 458625 [details] Patch
Created attachment 458630 [details] Patch
Comment on attachment 458630 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=458630&action=review > Source/WebCore/Modules/modern-media-controls/controls/overflow-button.js:53 > + for (let key in contextMenuOptions) > + return false; > + return true; This is clever, but it made me think twice about what it does and how it works. Is there a more obvious, or idiomatic, way of testing for an empty object?
Comment on attachment 458630 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=458630&action=review >> Source/WebCore/Modules/modern-media-controls/controls/overflow-button.js:53 >> + return true; > > This is clever, but it made me think twice about what it does and how it works. Is there a more obvious, or idiomatic, way of testing for an empty object? There are other ways of doing this (e.g. `Object.getOwnPropertyNames(contextMenuOptions).length`), but the primary issue with many of them is that they require iterating _all_ of the keys before returning a result. This approach is by far the most efficient in that it requires iterating only a single key. Yes, that isn't a huge problem here given that we (currently) will never have more than five keys, but I'd prefer to do the optimal thing nevertheless. FWIW this is used in Web Inspector as `isEmptyObject`, so there is some "prior art" :)
Committed r293658 (250162@main): <https://commits.webkit.org/250162@main> All reviewed patches have been landed. Closing bug and clearing flags on attachment 458630 [details].