File tree Expand file tree Collapse file tree 2 files changed +6
-17
lines changed Expand file tree Collapse file tree 2 files changed +6
-17
lines changed Original file line number Diff line number Diff line change 11import type { ObservedElement } from './ObservedElement' ;
22
33export interface ExtendedResizeObserverEntry extends ResizeObserverEntry {
4- readonly devicePixelContentBoxSize ?: ReadonlyArray < ResizeObserverSize > ; // https://github.com/w3c/csswg-drafts/pull/4476
54 target : ObservedElement ;
65}
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ import { Context } from './Context';
66const boxOptions = {
77 BORDER_BOX : 'border-box' , // https://caniuse.com/mdn-api_resizeobserverentry_borderboxsize
88 CONTENT_BOX : 'content-box' , // https://caniuse.com/mdn-api_resizeobserverentry_contentboxsize
9- DEVICE_PIXEL_CONTENT_BOX : 'device-pixel-content-box' // https://github .com/w3c/csswg-drafts/pull/4476
9+ DEVICE_PIXEL_CONTENT_BOX : 'device-pixel-content-box' // https://caniuse .com/mdn-api_resizeobserverentry_devicepixelcontentboxsize
1010} ;
1111
1212/**
@@ -55,21 +55,11 @@ export const useResizeObserver = (
5555 break ;
5656
5757 case boxOptions . DEVICE_PIXEL_CONTENT_BOX :
58- /* TypeScript 4.2 is missing devicePixelContentBoxSize. */
59- if ( typeof resizeObserverEntry . devicePixelContentBoxSize !== 'undefined' ) {
60- isIdentical = resizeObserverEntry . devicePixelContentBoxSize . every ( ( boxSize , index ) => {
61- if ( typeof observedEntry . devicePixelContentBoxSize !== 'undefined' ) {
62- return (
63- boxSize . inlineSize === observedEntry . devicePixelContentBoxSize [ index ] . inlineSize &&
64- boxSize . blockSize === observedEntry . devicePixelContentBoxSize [ index ] . blockSize
65- ) ;
66- } else {
67- throw Error ( 'resizeObserverEntry does not contain devicePixelContentBoxSize.' ) ;
68- }
69- } ) ;
70- } else {
71- throw Error ( 'resizeObserverEntry does not contain devicePixelContentBoxSize.' ) ;
72- }
58+ isIdentical = resizeObserverEntry . devicePixelContentBoxSize . every (
59+ ( boxSize , index ) =>
60+ boxSize . inlineSize === observedEntry . devicePixelContentBoxSize [ index ] . inlineSize &&
61+ boxSize . blockSize === observedEntry . devicePixelContentBoxSize [ index ] . blockSize
62+ ) ;
7363 break ;
7464
7565 default :
You can’t perform that action at this time.
0 commit comments