Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make arguments of Native functions optional #1678

Merged
merged 2 commits into from
Sep 2, 2024
Merged

Make arguments of Native functions optional #1678

merged 2 commits into from
Sep 2, 2024

Conversation

Jym77
Copy link
Contributor

@Jym77 Jym77 commented Sep 2, 2024

This makes them more flexible, notably for script injection:

  • inject(fromWindow) serialises fromWindow correctly but doesn't pass an argument.
  • inject(fromWindow, window) requires to have a handle (living in nodeJS world) on the window (living in the injection world), this is usually possible for DOM nodes, but not always for the window object itself.
  • inject( () => fromWindow(window) ) does not "recursively" serialise fromWindow which thus does not exists in the injection world. It would require using a bundler, or pre-injecting the function, … None of these being very convenient.

Now, inject(fromWindow) will work, defaulting to globalThis.window which is the most frequent case. If another window is needed, it can still be passed around (but then need to be provided by the caller).

@Jym77 Jym77 self-assigned this Sep 2, 2024
Copy link

changeset-bot bot commented Sep 2, 2024

🦋 Changeset detected

Latest commit: d8b3bbf

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 77 packages
Name Type
@siteimprove/alfa-dom Patch
@siteimprove/alfa-device Patch
@siteimprove/alfa-act Patch
@siteimprove/alfa-affine Patch
@siteimprove/alfa-applicative Patch
@siteimprove/alfa-aria Patch
@siteimprove/alfa-array Patch
@siteimprove/alfa-bits Patch
@siteimprove/alfa-branched Patch
@siteimprove/alfa-cache Patch
@siteimprove/alfa-callback Patch
@siteimprove/alfa-cascade Patch
@siteimprove/alfa-clone Patch
@siteimprove/alfa-collection Patch
@siteimprove/alfa-comparable Patch
@siteimprove/alfa-compatibility Patch
@siteimprove/alfa-continuation Patch
@siteimprove/alfa-css-feature Patch
@siteimprove/alfa-css Patch
@siteimprove/alfa-earl Patch
@siteimprove/alfa-either Patch
@siteimprove/alfa-emitter Patch
@siteimprove/alfa-encoding Patch
@siteimprove/alfa-equatable Patch
@siteimprove/alfa-flags Patch
@siteimprove/alfa-fnv Patch
@siteimprove/alfa-foldable Patch
@siteimprove/alfa-functor Patch
@siteimprove/alfa-future Patch
@siteimprove/alfa-generator Patch
@siteimprove/alfa-graph Patch
@siteimprove/alfa-hash Patch
@siteimprove/alfa-http Patch
@siteimprove/alfa-iana Patch
@siteimprove/alfa-iterable Patch
@siteimprove/alfa-json-ld Patch
@siteimprove/alfa-json Patch
@siteimprove/alfa-lazy Patch
@siteimprove/alfa-list Patch
@siteimprove/alfa-map Patch
@siteimprove/alfa-mapper Patch
@siteimprove/alfa-math Patch
@siteimprove/alfa-monad Patch
@siteimprove/alfa-network Patch
@siteimprove/alfa-option Patch
@siteimprove/alfa-parser Patch
@siteimprove/alfa-performance Patch
@siteimprove/alfa-predicate Patch
@siteimprove/alfa-promise Patch
@siteimprove/alfa-record Patch
@siteimprove/alfa-rectangle Patch
@siteimprove/alfa-reducer Patch
@siteimprove/alfa-refinement Patch
@siteimprove/alfa-result Patch
@siteimprove/alfa-rules Patch
@siteimprove/alfa-sarif Patch
@siteimprove/alfa-selective Patch
@siteimprove/alfa-selector Patch
@siteimprove/alfa-sequence Patch
@siteimprove/alfa-set Patch
@siteimprove/alfa-slice Patch
@siteimprove/alfa-string Patch
@siteimprove/alfa-style Patch
@siteimprove/alfa-table Patch
@siteimprove/alfa-test Patch
@siteimprove/alfa-thenable Patch
@siteimprove/alfa-thunk Patch
@siteimprove/alfa-time Patch
@siteimprove/alfa-toolchain Patch
@siteimprove/alfa-trampoline Patch
@siteimprove/alfa-tree Patch
@siteimprove/alfa-trilean Patch
@siteimprove/alfa-tuple Patch
@siteimprove/alfa-url Patch
@siteimprove/alfa-wcag Patch
@siteimprove/alfa-web Patch
@siteimprove/alfa-xpath Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@Jym77 Jym77 added the internal Change that only affects internal APIs or other non-public aspects label Sep 2, 2024
@Jym77 Jym77 marked this pull request as ready for review September 2, 2024 13:34
@Jym77 Jym77 requested a review from a team as a code owner September 2, 2024 13:34
@Jym77 Jym77 merged commit f26c0ec into main Sep 2, 2024
4 checks passed
@Jym77 Jym77 deleted the optional-from-args branch September 2, 2024 13:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
internal Change that only affects internal APIs or other non-public aspects
Projects
Status: 🏁 Done
Development

Successfully merging this pull request may close these issues.

1 participant