Skip to content

Make options.bindingGlobals empty by default#165

Merged
brianmhunt merged 4 commits into
knockout:mainfrom
bandcampdotcom:empty-bindingGlobals
Feb 15, 2022
Merged

Make options.bindingGlobals empty by default#165
brianmhunt merged 4 commits into
knockout:mainfrom
bandcampdotcom:empty-bindingGlobals

Conversation

@danieldickison

Copy link
Copy Markdown
Collaborator

This should make the default build safer by preventing access to things like document and fetch. For backwards compatibility, I think we need to keep window the bindingGlobals for the knockout build.

@brianmhunt
brianmhunt self-requested a review February 15, 2022 19:22

@brianmhunt brianmhunt left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Comment thread packages/utils/src/options.ts Outdated

// Global variables that can be accessed from bindings.
bindingGlobals: _global,
bindingGlobals: {},

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be Object.create(null) so there's no Object prototype chain to pollute. [1]

[1] https://stackoverflow.com/a/15518712/19212

@brianmhunt
brianmhunt merged commit 8b86273 into knockout:main Feb 15, 2022
@danieldickison
danieldickison deleted the empty-bindingGlobals branch February 15, 2022 19:39
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