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

Fix m.request/m.jsonp to not mutate arguments, simplify code #2288

Merged
merged 2 commits into from Nov 29, 2018

Conversation

@isiahmeadows
Copy link
Member

@isiahmeadows isiahmeadows commented Nov 9, 2018

Description

I basically recast it to remove 99% of the duplication. They're basically the same function mod how they fire their requests and append query parameters.

This also fixes the methods to be invoked with the expected this value, the options object, rather than this === undefined, which isn't documented.

Motivation and Context

#2254 stalled and I'd rather not pile yet another hack onto an already messy implementation. This does basically that, but better. I also saved 50 bytes min+gzip with my cleanup.

How Has This Been Tested?

Ran the tests as usual. I had to add a global for the mock, though - for some reason, we aren't testing FormData. (I didn't get around to actually adding new tests for it, though.)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation change

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • I have updated docs/change-log.md
@project-bot project-bot bot added this to Needs triage in Triage/bugs Nov 9, 2018
@isiahmeadows isiahmeadows moved this from Needs triage to High priority in Triage/bugs Nov 9, 2018
@isiahmeadows isiahmeadows requested a review from Nov 9, 2018
I basically recast it to remove 99% of the duplication. They're
basically the same function mod how they fire their requests and append
query parameters.
Copy link
Member

@barneycarroll barneycarroll left a comment

Nice one @isiahmeadows

Loading

@isiahmeadows isiahmeadows merged commit 7cbc15e into MithrilJS:next Nov 29, 2018
1 check passed
Loading
Triage/bugs automation moved this from High priority to Closed Nov 29, 2018
@isiahmeadows isiahmeadows deleted the request-fix branch Nov 29, 2018
@isiahmeadows isiahmeadows mentioned this pull request Dec 6, 2018
@qgustavor
Copy link
Contributor

@qgustavor qgustavor commented Dec 6, 2018

This commit broke this code:

m.request({
  url: '/some-example-url',
  responseType: 'arraybuffer',
  extract: xhr => xhr.response
})

This line is trying to read xhr.responseText even when args.extract is defined. Trying to read it throws a DOMException as it's not accessible when xhr.responseType is not '' or 'text'.

Loading

@isiahmeadows
Copy link
Member Author

@isiahmeadows isiahmeadows commented Dec 6, 2018

@qgustavor Please file a new issue with that bug.

Loading

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants