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

Global Namespace Pollution #224

Open
kpnielsen opened this issue Apr 14, 2023 · 0 comments
Open

Global Namespace Pollution #224

kpnielsen opened this issue Apr 14, 2023 · 0 comments

Comments

@kpnielsen
Copy link

xdomain pollutes the global namespace. In particular, it overrides window.FormData. This can break sites on which other scripts use FormData in fetch calls to submit forms via AJAX. To be more precise, consider the following call:

const myForm = document.getElementById('myForm')
myForm.addEventListener('submit', evt => {
  evt.preventDefault()

  fetch(form.dataset.ajaxUri, {
    method: 'POST',
    body: new FormData(form)
  }).then(result => {
    // do something with the result
  })
})

The payload of that request sent when submitting the form will not be the actual form data, but [object Object].

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

No branches or pull requests

1 participant