Skip to content

fix(polyfill): complete window timer and EventTarget aliases - #151

Merged
triniwiz merged 1 commit into
NativeScript:masterfrom
LorenzGit:neonleap/canvas-window-host
Sep 10, 2026
Merged

fix(polyfill): complete window timer and EventTarget aliases#151
triniwiz merged 1 commit into
NativeScript:masterfrom
LorenzGit:neonleap/canvas-window-host

Conversation

@LorenzGit

Copy link
Copy Markdown
Contributor

Problem

canvas-polyfill only installed window.addEventListener when both global and window lacked it. NativeScript often already has global.addEventListener, so window.addEventListener stayed missing. window.setTimeout was set without clearTimeout. Games that call window.matchMedia, document.documentElement.dataset, or style.setProperty throw at module eval.

Change

Fill each missing alias independently. Preserve existing implementations. Add clearTimeout/clearInterval, a matchMedia stub, devicePixelRatio, document.hidden/visibilityState, HTMLElement.dataset, and CSSStyleDeclaration.setProperty.

Test plan

Four listener-ownership cases (none / global / window / both) plus matchMedia are in NEONLEAP native/tests/window-host.test.ts. They fail on unpatched a2c279b8 and pass with this diff.

Independent of the empty-measureText PR.

NativeScript may install global.addEventListener before window exists,
so the old both-undefined guard left window.addEventListener missing.
Browser libraries bind window.setTimeout/clearTimeout/matchMedia and
documentElement.dataset / style.setProperty. Fill each alias independently.
@coderabbitai

coderabbitai Bot commented Sep 10, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 78cddcad-6e46-4ed4-a6e2-f73e4369f7cf

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@LorenzGit

Copy link
Copy Markdown
Contributor Author

The red AudioContext jobs are not from this diff.

  • iOS: NSCOpusDecoder.mm:7:10: fatal error: 'opusfile.h' file not found
  • Android: CMake add_subdirectory for missing third_party/oboe

The last Canvas Native run on master (merge of #149, run 34359199107) failed the same AudioContext jobs (and Canvas iOS/Android). This PR does not touch packages/audio-context.

The relevant job for this change is Build Native / Canvas iOS + visionOS.

@triniwiz
triniwiz merged commit 970bde0 into NativeScript:master Sep 10, 2026
4 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants