Commit graph

3431 commits

Author SHA1 Message Date
Isiah Meadows
86d64e213f
Fix #2443 (#2451) 2019-07-03 14:41:48 -04:00
Isiah Meadows
ddc8adbbd3
Fix #2424 (#2450)
* Fix #2424

* Add PR ref
2019-07-03 14:41:37 -04:00
Isiah Meadows
d629c7aef8
Fix #2442 (#2449)
* Fix #2442

* Add PR link
2019-07-03 12:43:38 -04:00
Isiah Meadows
85bfd0f77d
Clarify pathname docs, follow spec with fragments (#2448)
* Clarify pathname docs, follow spec with fragments

- Valid URLs must not contain a `#` within its fragment.
  https://github.com/MithrilJS/mithril.js/issues/2445
- Our docs were a little confusing and misleading - `m.pathname` isn't
  aware of URLs, just path names.
- Removed the relevant extension to `m.parseQueryString` required to
  support the hash parsing extension. Now we just shave it off and
  ignore it.
- Fix support for arbitrary prefixes, so prefixes like `?#` are
  handled correctly.
- Add a bunch of tests to cover various areas of confusion and unusual
  edge cases.

* Update with PR [skip ci]
2019-07-03 06:22:25 -04:00
Isiah Meadows
9e9b89d900
Fix #2067 (#2447)
* Fix #2067

* Add PR number [skip ci]
2019-07-03 04:53:45 -04:00
spacejack
696b5cbfe3 Edit types installation to be clearer and easier to find (#2435) 2019-06-20 07:02:02 -04:00
Daniel Loomer
10f0b4934a support falsy arguments in Object.assign polyfill (#2433)
* support falsy arguments in Object.assign polyfill

* add tests for assign polyfill
2019-06-15 22:48:24 -04:00
Stephan Hoyer
dd6572579d
Create FUNDING.yml 2019-06-14 14:51:12 +02:00
Isiah Meadows
9d6fc3e910
Update CODEOWNERS 2019-06-13 13:23:11 -04:00
Woody Gilk
6f602de878 Improve initial request docs example (#2430) 2019-06-12 05:53:59 -04:00
Isiah Meadows
0150e39275 Update issue templates [skip ci] 2019-06-11 08:05:00 -04:00
Isiah Meadows
0a1a33a036
Make m.request work with async/await correctly. (#2428)
* s/xhr/request/g

`m.xhr` was a relic of the rewrite days prior to the release of v1.0.0,
before it was renamed `m.request` to align with v0.2.x. This just strips
some of that legacy naming.

* Make this work with `async`/`await` correctly.

It looked like a V8 bug, but read the two big code comments and follow
their links. It's a bit more subtle than it looks, and V8's in the right
here.
2019-06-10 19:48:04 -04:00
Erik Vullings
8a7eae00ed Fix for #2423. request.data => body, params is used for querystrings (#2425)
* Fix for #2423. request.data is replaced by body, params is used for querystring interpolation.

* Updated documentation after code review by shadowhand and isiahmeadows

* Convert indentation to tabs

* Replacing m.request.data and m.jsonp.data with params or body.

* Update request.md


Co-authored-by: Isiah Meadows <contact@isiahmeadows.com>
2019-06-10 19:36:32 -04:00
Isiah Meadows
e82f6d00c2 v2.0.0-rc.6 2019-05-31 12:14:27 -04:00
Isiah Meadows
06e94e5206 Bundled commit for 0ce3aa066a [skip ci] 2019-05-31 12:07:35 -04:00
Isiah Meadows
0ce3aa066a
Fix #2419 (#2421)
* Fix #2419

* Update the changelog
2019-05-31 10:37:06 -04:00
Isiah Meadows
0306401a76
Add missing line
Drive-by: fix formatting error in v2.0.0 section

Fixes #2418
2019-05-30 21:06:52 -04:00
Isiah Meadows
41e8b614e1 Maybe *this* time, everything should magically work... 2019-05-29 11:44:57 -04:00
Isiah Meadows
836d35a6e3 This folder shouldn't have been committed 2019-05-29 11:18:38 -04:00
Isiah Meadows
3befb96909 Regenerate docs since I seem to be having Travis permission errors... 2019-05-29 10:30:15 -04:00
Isiah Meadows
f1d001cfcd v2.0.0-rc.5 2019-05-29 10:23:40 -04:00
Isiah Meadows
7fb47852c0 Run npm audit fix and prune 2019-05-29 10:23:18 -04:00
Isiah Meadows
3b301d928e Merge branch 'next' 2019-05-29 10:18:48 -04:00
Isiah Meadows
51e0aee2ab Update SSH key because I'm apparently dumb
- The SSH issue does appear *fixed*.
2019-05-29 10:10:53 -04:00
Isiah Meadows
89e1f5d8d3 Attempt to fix docs generation issues 2019-05-29 09:57:16 -04:00
Stephan Hoyer
852fd1b166 Update docs/request.md
Co-Authored-By: isiahmeadows <contact@isiahmeadows.com>
2019-05-29 09:44:31 -04:00
Isiah
09ccf0e3b3 Bundled output for commit 794e8e963f [skip ci] 2019-05-29 13:43:31 +00:00
Isiah Meadows
794e8e963f
Bring some sanity to request parsing and error handling (#2335)
* Update docs/request.md
* Bring some sanity to request parsing and error handling

- The browser can do JSON parsing itself. Let's defer to that where
  possible. (A few IE hacks are required here, though.)
- Don't propagate any error that occurs before `deserialize`/`extract`.
- Allow sending raw array buffers/blobs/etc. to `deserialize`.
- Align behavior more closely with the XHR spec.
- Send the more useful parsed response to `deserialize`, not the less
  useful string response.
2019-05-29 09:41:22 -04:00
Isiah
09afc54c7b Bundled output for commit 58f1c74394 [skip ci] 2019-05-29 13:30:52 +00:00
Isiah Meadows
58f1c74394
Streamline route/request path handling and split params + body in requests (#2361)
Fixes #2360
Fixes #1138
Fixes #1788 a little less hackishly
Probably fixes a few other issues I'm not aware of.

This more or less goes with @lhorie's comment here, just with a minor name
change from `query` to `params`:

https://github.com/MithrilJS/mithril.js/issues/1138#issuecomment-231363395

Specifically, here's what this patch entails:

- I changed `data` and `useBody` to `params` and `body` in `m.request`.
  Migration is trivial: just use `params` or `body` depending on which you
  intend to send. Most servers do actually care where the data goes, so you can
  generally pretty easily translate this accordingly. If you *really* need the
  old behavior, pass the old value in `params` and if `method === "GET"` or
  `method === "TRACE"`, also in `body`.
- I opened up all methods to have request bodies.
- I fixed `m.parseQueryString` to prefer later values over earlier values and
  to ensure that objects and arrays are persisted across both hash and query
  param parsing. That method also accepts an existing key/value map to append
  to, to simplify deduplication.
- I normalized path interpolation to be identical between routes and requests.
- I no longer include interpolated values in query strings. If you need to
  duplicate values again, rename the interpolation to be a distinct property
  and pass the value you want to duplicate as it.
- I converted `m.route` to use pre-compiled routes instead of its existing
  system of dynamic runtime checking. This shouldn't have a major effect on
  performance short-term, but it'll ease the migration to built-in userland
  components and make it a little easier to reconcile. It'll also come handy
  for large numbers of routes.
- I added support for matching routes like `"/:file.:ext"` or
  `"/:lang-:region"`, giving each defined semantics.
- I added support for matching against routes with static query strings, such
  as `"/edit?type=image": { ... }`.
- I'm throwing a few new informative errors.
- And I've updated the docs accordingly.

I also made a few drive-by edits:

- I fixed a bug in the `Stream.HALT` warning where it warned all but the first
  usage when the intent was to warn only on first use.
- Some of the tests were erroneously using `Stream.HALT` when they should've
  been using `Stream.SKIP`. I've fixed the tests to only test that
  `Stream.HALT === Stream.SKIP` and that it only warns on first use.
- The `m.request` and `m.jsonp` docs signatures were improved to more clearly
  explain how `m.request(url, options?)` and `m.jsonp(url, options?)` translate
  to `m.request(options)` and `m.jsonp(options)` respectively.

-----

There is some justification to these changes:

- In general, it matters surprisingly more than you would expect how things
  translate to HTTP requests. So the comment there suggesting a thing that
  papers over the difference has led to plenty of confusion in both Gitter and
  in GitHub issues.

- A lot of servers expect a GET with a body and no parameters, and leaving
  `m.request` open to working with that makes it much more flexible.

- Sometimes, servers expect a POST with query parameters *instead* of a JSON
  object. I've seen this quite a bit, even with more popular REST APIs like
  Stack Overflow's.

- I've encountered a few servers that expect both parameters and a body, each
  with distinct semantic meaning, so the separation makes it much easier to
  translate into a request.

- Most of the time, path segments are treated individually, and URL-escaping
  the contents is much less error-prone. It also avoids being potentially
  lossy, and when the variable in question isn't trusted, escaping the path
  segment enables you to pass it through the URL and not risk being redirected
  to unexpected locations, avoiding some risks of vulnerabilities and client
  side crashes.

If you really don't care how the template and parameters translate to an
eventual URL, just pass the same object for the `params` and `body` and use
`:param...` for each segment. Either way, the more explicit nature should help
a lot in making the intent clearer, whether you care or not.
2019-05-29 09:28:40 -04:00
Isiah Meadows
b17b00e9eb
Drop ESM support (#2366)
* Drop ESM support

* Add `"unpkg"` field
2019-05-29 09:24:10 -04:00
Daniel Loomer
9b38e41fd6 standardize cdn links in docs (#2416)
- consistently use @next and explicit path
2019-05-27 11:58:11 -04:00
Rishabh Rawat
61af23de24 Adding fallback font-family sans-serif (#2411) 2019-05-14 13:52:56 -04:00
Oscar
6d36fe09d1 fix small typos (#2409)
Bootstrap FullCalandar Example -> Bootstrap FullCalendar Example
console.log('FullCalndar::oncreate') -> console.log('FullCalendar::oncreate')
2019-04-27 20:47:44 -04:00
Oscar
db0b5e26ba fix small typo (#2408)
m.route.params() -> m.route.param()
2019-04-23 06:59:08 -04:00
Isiah Meadows
000bb5aa55
Fix #2379 2019-04-17 14:30:46 -04:00
Ayush Jain
982fdf5737 Corrected the case issue of 'JavaScript' throughout the docs (#2401)
* corrected JavaScript spelling
2019-04-01 08:14:38 -04:00
Isiah
44fac6c4ca Bundled output for commit 0707de5867 [skip ci] 2019-03-09 07:06:45 +00:00
Isiah Meadows
0707de5867
Swap out keys so they use mine (#2393) 2019-03-09 02:04:30 -05:00
Gandalf-the-Bot
a154ace889 Bundled output for commit b0e4f4f2f8 [skip ci] 2019-03-02 07:38:55 +00:00
Isiah Meadows
b0e4f4f2f8 Run npm audit fix 2019-03-02 02:37:08 -05:00
Arun Cvf
853a54ae79 Fix mixed content error. (#2383)
Mixed Content: The page at 'https://cdn.rawgit.com/MithrilJS/mithril.js/master/examples/threaditjs/index.html' was loaded over HTTPS, but requested an insecure stylesheet 'http://threaditjs.com/reset.css'. This request has been blocked; the content must be served over HTTPS.
2019-03-02 02:22:39 -05:00
tebe
8e7f85f389 Fixed wrong setItem params (#2381) 2019-02-25 14:19:42 -05:00
Isiah Meadows
2010a0a71a Mithril now accepts donations through OpenCollective (#2363)
* Mithril now accepts donations through OpenCollective

* Include both backers and sponsors

* Add a contributing TOC, retitle page, fix a few links
2019-02-18 14:26:12 -05:00
Gandalf-the-Bot
9550730e99 Bundled output for commit ddec23efe7 [skip ci] 2019-02-18 19:24:58 +00:00
Isiah Meadows
ddec23efe7
Mithril now accepts donations through OpenCollective (#2363)
* Mithril now accepts donations through OpenCollective

* Include both backers and sponsors

* Add a contributing TOC, retitle page, fix a few links
2019-02-18 14:21:13 -05:00
Gandalf-the-Bot
621352fbd7 Bundled output for commit a9172f1129 [skip ci] 2019-02-07 10:14:46 +00:00
Yogesh Khatri
a9172f1129 Feature onmatch route param (#2371)
* added route param in onmatch

* fix docs

* included test

* docs fix
2019-02-07 05:12:53 -05:00
Isiah Meadows
6f8f011b88
Small typo fix (#2372) 2019-02-07 04:20:26 -05:00
Isiah Meadows
beb129c5fb Prepare ospec@3.1.0, mithril-stream@2.0.0
Also, correct the change logs to be much more consistent between each
other and ensure the ospec and stream change logs are linked to from
Mithril's primary change log.
2019-02-07 04:10:12 -05:00