Skip to content

Commit

Permalink
fix: remove unneeded shims, setTimeout is support
Browse files Browse the repository at this point in the history
ed everywhere
  • Loading branch information
luwes committed Jul 13, 2023
1 parent 610d490 commit e6a61b6
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 17 deletions.
4 changes: 2 additions & 2 deletions src/js/experimental/media-chrome-listbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -419,10 +419,10 @@ class MediaChromeListbox extends globalThis.HTMLElement {
}

#clearKeysOnDelay() {
globalThis.clearTimeout(this.#clearKeysTimeout);
clearTimeout(this.#clearKeysTimeout);
this.#clearKeysTimeout = null;

this.#clearKeysTimeout = globalThis.setTimeout(() => {
this.#clearKeysTimeout = setTimeout(() => {
this.#keysSoFar = '';
this.#clearKeysTimeout = null;
}, 500);
Expand Down
8 changes: 4 additions & 4 deletions src/js/media-container.js
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ class MediaContainer extends globalThis.HTMLElement {
if (pendingResizeCb) return;
// Just in case it takes too long (which will cause an error to throw),
// do the breakpoint computation asynchronously
globalThis.setTimeout(() => {
setTimeout(() => {
resizeCallback(entries);
// Once we've completed, reset the pending cb flag to false
pendingResizeCb = false;
Expand Down Expand Up @@ -481,12 +481,12 @@ class MediaContainer extends globalThis.HTMLElement {
const scheduleInactive = () => {
setActive();

globalThis.clearTimeout(this._inactiveTimeout);
clearTimeout(this._inactiveTimeout);

Check warning on line 484 in src/js/media-container.js

View check run for this annotation

Codecov / codecov/patch

src/js/media-container.js#L484

Added line #L484 was not covered by tests

// Setting autohide to -1 turns off autohide
if (this.autohide < 0) return;

this._inactiveTimeout = globalThis.setTimeout(() => {
this._inactiveTimeout = setTimeout(() => {

Check warning on line 489 in src/js/media-container.js

View check run for this annotation

Codecov / codecov/patch

src/js/media-container.js#L489

Added line #L489 was not covered by tests
setInactive();
}, this.autohide * 1000);
};
Expand Down Expand Up @@ -527,7 +527,7 @@ class MediaContainer extends globalThis.HTMLElement {

setActive();
// Stay visible if hovered over control bar
globalThis.clearTimeout(this._inactiveTimeout);
clearTimeout(this._inactiveTimeout);

Check warning on line 530 in src/js/media-container.js

View check run for this annotation

Codecov / codecov/patch

src/js/media-container.js#L530

Added line #L530 was not covered by tests

// If hovering over something other than controls, we're free to make inactive
// @ts-ignore
Expand Down
11 changes: 0 additions & 11 deletions src/js/utils/server-safe-globals.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,6 @@ const globalThisShim = {
},
CustomEvent: function CustomEvent() {},
getComputedStyle: function () {},
// eslint-disable-next-line no-unused-vars
requestAnimationFrame: function(_cb) {
return 1;
},
// eslint-disable-next-line no-unused-vars
queueMicrotask: function(_cb) {
},
};

export const isServer =
Expand All @@ -60,17 +53,13 @@ const isShimmed = Object.keys(globalThisShim)
* getComputedStyle,
* addEventListener?,
* removeEventListener?,
* setTimeout?,
* clearTimeout?,
* localStorage?,
* WebKitPlaybackTargetAvailabilityEvent?,
* window?,
* document?,
* chrome?,
* DocumentFragment?,
* ResizeObserver?,
* requestAnimationFrame,
* queueMicrotask,
* CastableVideoElement?
* } }
* */
Expand Down

0 comments on commit e6a61b6

Please sign in to comment.