Skip to content

Global Namespace Pollution #224

Description

@kpnielsen

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].

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions