diff options
Diffstat (limited to 'ext/web')
-rw-r--r-- | ext/web/02_event.js | 13 | ||||
-rw-r--r-- | ext/web/06_streams.js | 28 | ||||
-rw-r--r-- | ext/web/15_performance.js | 23 |
3 files changed, 38 insertions, 26 deletions
diff --git a/ext/web/02_event.js b/ext/web/02_event.js index d8b595c54..677768ac9 100644 --- a/ext/web/02_event.js +++ b/ext/web/02_event.js @@ -32,6 +32,7 @@ ObjectGetOwnPropertyDescriptor, ObjectPrototypeIsPrototypeOf, ReflectDefineProperty, + ReflectHas, SafeArrayIterator, StringPrototypeStartsWith, Symbol, @@ -104,7 +105,7 @@ function hasRelatedTarget( event, ) { - return "relatedTarget" in event; + return ReflectHas(event, "relatedTarget"); } const isTrusted = ObjectGetOwnPropertyDescriptor({ @@ -450,7 +451,7 @@ function isNode( eventTarget, ) { - return Boolean(eventTarget && "nodeType" in eventTarget); + return Boolean(eventTarget && ReflectHas(eventTarget, "nodeType")); } // https://dom.spec.whatwg.org/#concept-shadow-including-inclusive-ancestor @@ -485,7 +486,7 @@ function isSlotable( nodeImpl, ) { - return Boolean(isNode(nodeImpl) && "assignedSlot" in nodeImpl); + return Boolean(isNode(nodeImpl) && ReflectHas(nodeImpl, "assignedSlot")); } // DOM Logic functions @@ -908,7 +909,7 @@ options = normalizeAddEventHandlerOptions(options); const { listeners } = (this ?? globalThis)[eventTargetData]; - if (!(type in listeners)) { + if (!(ReflectHas(listeners, type))) { listeners[type] = []; } @@ -952,7 +953,7 @@ }); const { listeners } = (this ?? globalThis)[eventTargetData]; - if (callback !== null && type in listeners) { + if (callback !== null && ReflectHas(listeners, type)) { listeners[type] = ArrayPrototypeFilter( listeners[type], (listener) => listener.callback !== callback, @@ -989,7 +990,7 @@ const self = this ?? window; const { listeners } = self[eventTargetData]; - if (!(event.type in listeners)) { + if (!ReflectHas(listeners, event.type)) { setTarget(event, this); return true; } diff --git a/ext/web/06_streams.js b/ext/web/06_streams.js index 7ef5a6131..6daea0898 100644 --- a/ext/web/06_streams.js +++ b/ext/web/06_streams.js @@ -41,6 +41,7 @@ PromiseResolve, queueMicrotask, RangeError, + ReflectHas, SharedArrayBuffer, Symbol, SymbolAsyncIterator, @@ -190,7 +191,7 @@ * @returns {boolean} */ function isDetachedBuffer(O) { - return isFakeDetached in O; + return ReflectHas(O, isFakeDetached); } /** @@ -392,7 +393,10 @@ * @returns {T} */ function dequeueValue(container) { - assert(_queue in container && _queueTotalSize in container); + assert( + ReflectHas(container, _queue) && + ReflectHas(container, _queueTotalSize), + ); assert(container[_queue].length); const valueWithSize = ArrayPrototypeShift(container[_queue]); container[_queueTotalSize] -= valueWithSize.size; @@ -410,7 +414,10 @@ * @returns {void} */ function enqueueValueWithSize(container, value, size) { - assert(_queue in container && _queueTotalSize in container); + assert( + ReflectHas(container, _queue) && + ReflectHas(container, _queueTotalSize), + ); if (isNonNegativeNumber(size) === false) { throw RangeError("chunk size isn't a positive number"); } @@ -592,7 +599,7 @@ */ function isReadableStream(value) { return !(typeof value !== "object" || value === null || - !(_controller in value)); + !ReflectHas(value, _controller)); } /** @@ -612,7 +619,7 @@ */ function isReadableStreamDefaultReader(value) { return !(typeof value !== "object" || value === null || - !(_readRequests in value)); + !ReflectHas(value, _readRequests)); } /** @@ -621,7 +628,7 @@ */ function isReadableStreamBYOBReader(value) { return !(typeof value !== "object" || value === null || - !(_readIntoRequests in value)); + !ReflectHas(value, _readIntoRequests)); } /** @@ -639,7 +646,7 @@ */ function isWritableStream(value) { return !(typeof value !== "object" || value === null || - !(_controller in value)); + !ReflectHas(value, _controller)); } /** @@ -659,7 +666,10 @@ * @returns {T | _close} */ function peekQueueValue(container) { - assert(_queue in container && _queueTotalSize in container); + assert( + ReflectHas(container, _queue) && + ReflectHas(container, _queueTotalSize), + ); assert(container[_queue].length); const valueWithSize = container[_queue][0]; return valueWithSize.value; @@ -4333,7 +4343,7 @@ highWaterMark, ); } else { - assert(!("type" in underlyingSourceDict)); + assert(!(ReflectHas(underlyingSourceDict, "type"))); const sizeAlgorithm = extractSizeAlgorithm(strategy); const highWaterMark = extractHighWaterMark(strategy, 1); setUpReadableStreamDefaultControllerFromUnderlyingSource( diff --git a/ext/web/15_performance.js b/ext/web/15_performance.js index c48a3d888..41b40159e 100644 --- a/ext/web/15_performance.js +++ b/ext/web/15_performance.js @@ -10,6 +10,7 @@ ArrayPrototypeSlice, ObjectKeys, ObjectPrototypeIsPrototypeOf, + ReflectHas, Symbol, SymbolFor, TypeError, @@ -470,17 +471,17 @@ throw new TypeError("Options cannot be passed with endMark."); } if ( - !("start" in startOrMeasureOptions) && - !("end" in startOrMeasureOptions) + !ReflectHas(startOrMeasureOptions, "start") && + !ReflectHas(startOrMeasureOptions, "end") ) { throw new TypeError( "A start or end mark must be supplied in options.", ); } if ( - "start" in startOrMeasureOptions && - "duration" in startOrMeasureOptions && - "end" in startOrMeasureOptions + ReflectHas(startOrMeasureOptions, "start") && + ReflectHas(startOrMeasureOptions, "duration") && + ReflectHas(startOrMeasureOptions, "end") ) { throw new TypeError( "Cannot specify start, end, and duration together in options.", @@ -492,13 +493,13 @@ endTime = convertMarkToTimestamp(endMark); } else if ( typeof startOrMeasureOptions === "object" && - "end" in startOrMeasureOptions + ReflectHas(startOrMeasureOptions, "end") ) { endTime = convertMarkToTimestamp(startOrMeasureOptions.end); } else if ( typeof startOrMeasureOptions === "object" && - "start" in startOrMeasureOptions && - "duration" in startOrMeasureOptions + ReflectHas(startOrMeasureOptions, "start") && + ReflectHas(startOrMeasureOptions, "duration") ) { const start = convertMarkToTimestamp(startOrMeasureOptions.start); const duration = convertMarkToTimestamp(startOrMeasureOptions.duration); @@ -509,13 +510,13 @@ let startTime; if ( typeof startOrMeasureOptions === "object" && - "start" in startOrMeasureOptions + ReflectHas(startOrMeasureOptions, "start") ) { startTime = convertMarkToTimestamp(startOrMeasureOptions.start); } else if ( typeof startOrMeasureOptions === "object" && - "end" in startOrMeasureOptions && - "duration" in startOrMeasureOptions + ReflectHas(startOrMeasureOptions, "end") && + ReflectHas(startOrMeasureOptions, "duration") ) { const end = convertMarkToTimestamp(startOrMeasureOptions.end); const duration = convertMarkToTimestamp(startOrMeasureOptions.duration); |