Commit graph

81 commits

Author SHA1 Message Date
Stephan Hoyer
716d1e1804 Kick jsonp - fixes #2682 2022-06-06 12:56:25 +02:00
Stephan Hoyer
94774e73b0 Center docs again 2022-02-27 18:54:11 +01:00
Stephan Hoyer
1a4b794be7 Fix lint errors 2022-02-22 09:01:10 +01:00
Barney Carroll
31d2ed4be8 Tests use hyperscript instead of manually constructing nodes 2022-02-12 12:19:35 +01:00
James Cote
99c6d813d2
Send URLSearchParams as request body without extra configuration (#2695) 2022-01-31 10:12:02 +01:00
Claudia Meadows
3b1bc04b9e
Delete test-utils/README.md (#2674) 2021-04-17 13:04:55 -07:00
Kevin Fiol
f5b41aaf0f
Reject request on XHR timeout (#2646)
Co-authored-by: Zachary Hamm <hamm.zachary@gmail.com>
2020-12-23 02:42:03 -08:00
Isiah Meadows
9f0dc2ab46
Runtime-deprecate ospec, change change-log to changelog, fix a few assorted bugs (#2578) 2020-09-29 13:27:07 -07:00
Isiah Meadows
d4551f49f5
Add streams to releases again, include minified bundle, drop in… (#2539)
* Minify stream, add stream stuff to releases again

* Kill off a lot of tech debt, drop internal utilities from npm

1. Kill `module/`, internalize `bundler/`, privatize `test-utils/`

We've been telling people to move elsewhere from these for a while, and
it's about time we just pull the plug here and finally remove them.

- We officially removed the bundler from the public API in v2.0, and
  that was the only one of these that was ever publicly documented.
  Usage should be low enough by now it shouldn't break anyone- I'm not
  seeing bundler bugs being reported anymore, either.
- The `module/` utility was so narrow and caveat-filled that I'm not
  sure anyone really used it (even us core Mithril devs never really
  used it), and we only had it documented in the repo folder it lived
  in. I think only one bug was ever filed, and it's because it somehow
  ended up completely non-functional without any of us realizing it.
- The test utilities were meant to be internal from day 1, but people
  started using it despite us core developers constantly telling people
  to look elsewhere and even the docs recommending specific alternatives
  without mention of our internal mocks. (Now if people would RTFM,
  that'd be nice...)

2. Add dedicated HTML test files to verify ospec and the promise
   polyfill, and ensure the promise tests are in pure ES5.

These are made specially for those and should be much easier to just run
now.

3. Fix the benchmark script to use the real DOM in browsers and to not
   require as many dependencies to create. Also, tweak them to be much
   more effective and precise on what's being tested.

Previously, it was rendering to the HTML file itself, while now it's
rendering to the `body`. This means in browsers, it's triggering layout
and everything, benchmarking how well Mithril optimizes for style and
layout recalcs, too. It also puts some pressure on the hyperscript
parser attribute application, so that can be noticed as well.

* Update dependencies
2019-10-03 04:58:14 -04:00
Isiah Meadows
b98ab29efd
Make errors and their messages more accurate and helpful (#2536)
Also, I normalized them to all be sentences for consistency, and I moved
the reentrancy check from `m.mount` to `m.render` to be a little more
helpful. The router change during mounting is inconsequential and only
to avoid the new modified error, and the change to the update loop is to
send the original error if an error occurred while initializing the
default route. (This is all around more useful anyways.)

And while I was at it, I fixed an obscure bug with sync redraws.
2019-09-30 16:08:04 -04:00
Isiah Meadows
39fa2b32c2
Fix #1881 + related ospec bug (#2492)
* Fix #1881 + related ospec bug

* Test duplicate resolves, update changelog
2019-07-26 18:19:40 -04:00
Isiah Meadows
234b1c9302 Update migration, fix various minor issues
- Lot of people couldn't migrate to v1 and plan to reevaluate when v2 is
  released.
- It's "npm" not "NPM". It doesn't stand for anything, and it never
  has - it was initially chosen simply because it was easy to type.
  It has a lot of unofficial backronyms with "Node Package Manager"
  being one of the most common ones, but it's never officially stood
  for anything as an acronym *or* initialism.
- Fixed a few errors in the change log, like non-breaking changes being
  included in the "Breaking Changes" section and an inaccuracy in the
  summary of a particular change.
- Fixed RawGit URLs to point to GitHack, which is a lighter proxy that
  offloads caching to Cloudflare instead of also implementing it itself.
  (It also just uses nginx for all the important server logic, so it
  scales better.)
- Add a few more v0.2 references as appropriate
2019-07-24 05:01:20 -04:00
Isiah Meadows
4cbcaf2936
Fix link + docs (#2476)
* Fix a copy/paste fail

Also, fix some incorrect tests.

* Clarify how routes are diffed, improve key + route resolver docs

- Add some missing links to route resolvers and single-child keyed
  fragments, clarify usage around them.
- Drive-by: remove a redundant sentence that itself was missing a
  period.

* Actually test for propagation and preventDefault

Previously, the mocks were both junk and inaccurate. No wonder my tests
were silently failing - they were wrong and not obviously wrong.
2019-07-16 16:03:24 -04:00
Isiah Meadows
582bda56dc
Partially recast the router API to be a lot more intuitive. (#2469)
* Recast the router API to be a lot more intuitive.

Fixes #2387
Fixes #2072
Fixes quite a few issues reported on Gitter.

For `m.route.Link`:

- More intuitive
- More accessible
- More ergonomic
- It can be disabled
- It can be cancelled
- It can be changed
- Oh, and you can use it isomorphically.

For `m.route.prefix`

- You can *read* it.
- You can write to it, of course.
- It's literally just setting a property.

For the router itself (and the rest of Mithril):

- You can now `require("mithril")` and all its submodules without a DOM
  at all. There is a catch: you can't instantiate any routes, you can't
  mount anything, and you can't invoke `m.render` in any capacity. You
  can only use `m.route.Link`, `m.route.prefix`, hyperscript stuff, and
  `mithril/stream`, and you can use `m.request` with `background: true`
  if you use a global XHR polyfill. (You can't use `m.request` without
  `background: true` except with a DOM to redraw with.) The goal here is
  to try to get out of the way for simple testing and to defer the
  inevitable `TypeError`s for the relevant DOM methods to runtime.

  The factory requires no arguments, and in terms of globals, you can
  just figure out based on what errors are thrown what globals to
  define. Their values don't matter - they just need to be set to
  *something*, even if it's just `null` or `undefined`, before Mithril
  executes.

Had to make quite a few other changes throughout the docs and tests to
update them accordingly. Oh, and that massive router overhaul enabled me
to do all this.

Also, slip in a few drive-by fixes to the mocks so they're a little
easier to work with and can accept more URLs. This was required for a
few of the tests.

* Update changelog + numbers, add forgotten bundle option

* Add PR numbers to changelog [skip ci]

* Allow continuing to the next match by returning `false`.

* Update numbers again
2019-07-12 15:29:37 -04:00
Isiah Meadows
1f4b2cf49a
Deservicify core (#2458)
* De-servicify router (mostly)

Still uses the redraw service, but it no longer has an intermediate
service of its own.

Also, did a *lot* of test deduplication in this. About 30-40% of the
router service tests were already tested on the main router API instance
itself.

Bundle size decreased from 9560 to 9548 bytes min+gzip.

* Merge `m.mount` + `m.redraw`, update router

Simplifies the router and redraw mechanism, and makes it much easier to
keep predictable.

Bundle size down to 9433 bytes min+gzip, docs updated accordingly.

* Make `mithril/render` just return the `m.render` function directly.

* Deservicify `m.render`, revise `m.route`

- You now have to use `mithril/render/render` directly if you want an
  implicit redraw function. (This will likely be going away in v3.)
- Revise `m.route` to only `key` components

* Add `redraw` to `m.render`, deservicify requests

* Test error logging

* Update docs + changelog [skip ci]
2019-07-07 18:28:43 -04:00
Isiah Meadows
8eed896859
Track XHR replacements correctly (#2455)
* Track XHR replacements correctly

Fixes #2439

* Update docs [skip ci]
2019-07-05 19:50:51 -04:00
Isiah Meadows
90bcff0fa7
Deduplicate m.route and m.redraw logic (#2453)
- Remove appropriate route change subcriptions when a root is removed
  via `m.mount(root, null)`.
- Don't pollute `onpopstate` and friends - use standard event listeners
  instead.
- Simplify and streamline subscriptions, in preparation of adding a
  `remove` parameter to `m.mount`.
- Change the redraw internals to redraw immediately, with ability to
  cancel via returning a sentinel.
- Change `"bleeding-edge"` for `m.version` in `next` to instead just be
  the latest `m.version`. (If you're using `next`, you should know what
  you're in for.)
- Update tests to be aware of these changes. (Some were failing for
  subtle reasons.)
- Drive-by: remove some uses of `string.charAt(n)` and use `string[n]`
  instead.
2019-07-05 18:52:06 -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
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 Meadows
7cbc15e7a2
Fix m.request/m.jsonp to not mutate arguments, simplify code (#2288)
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.
2018-11-28 20:10:46 -05:00
Isiah Meadows
4a641092dc
Officially drop IE9-10 support, pull out our hacks (#2296)
- I also fixed a bunch of related comments
- I had to polyfill `requestAnimationFrame` for Node
- Drive-by: run `eslint . --fix`
- Drive-by: update transpiling info in CONTRIBUTING.md
- Drive-by: we aren't the only ones going semicolon-free
2018-11-27 18:04:15 -05:00
Rasmus Porsager
7c299ab48c Allow css vars with uppercase characters (#2311)
* Allow css vars with uppercase characters

* Remove charAt

* Extract dash lowercase lambda

* Extract match uppercase regex

* Set key and value correctly in updateStyle

* Fix domMock style to work like the browser
2018-11-26 09:40:08 -05:00
Barney Carroll
4c5968a526 Fix #2192 (#2308)
* Fix #2192

* Fix mock style property definitions

* Re-instate camelCased style property key declaration support

* Fix removeProperty, eslint fix

* Stringify style keys: fix perf tests

* Fix weird uncaught mixed whitespace

* Fix weird uncaught mixed whitespace
2018-11-26 05:49:16 -05:00
Isiah Meadows
4d579c50b6
Revert "Fix #1771 and probably others (#2286)" (#2299)
4f68984f2f
2018-11-14 19:26:23 -05:00
Isiah Meadows
4f68984f2f
Fix #1771 and probably others (#2286)
This is *super* subtle, and IMHO Chrome did exactly the wrong thing
here.
2018-11-14 15:35:00 -05:00
Isiah Meadows
c703b03253
Unbreak accidental back-compat break with event optimization (#2222)
This was supposed to be purely additive. See here for more details:

https://github.com/MithrilJS/mithril.js/pull/1949#issuecomment-417824513
2018-09-18 10:14:21 -04:00
Pierre-Yves Gérardy
6283aa4a7d [render/render] Test for removing styles and assorted domMock changes 2018-06-01 21:27:02 +02:00
Pierre-Yves Gérardy
b39f4f683d [domMock] Better accuracy for namespaced elements 2018-06-01 21:27:02 +02:00
Pierre-Yves Gérardy
e3b240032a [domMock] don't call public methods from DOM API methods (it messes up spying) 2018-05-29 23:50:29 +02:00
Pierre-Yves Gérardy
9136585fe4 [DOM Mock] Fix insertBefore when the reference node follows the moving child in a nodeList 2018-04-23 13:52:03 +02:00
Pierre-Yves Gérardy
fdd34f9726 [mocks] Add some support for parsing SVG using the DOMParser API and innerHTML 2018-03-06 01:12:32 +01:00
magikstm
e64a322bcf Correct test scripts 2017-12-30 04:44:00 -05:00
Pierre-Yves Gérardy
12d3540d47 domMock: implement event propagation 2017-12-03 01:16:22 +01:00
Isiah Meadows
348bed0a7e Allow xlink:href to get removed, fix option.value in mock 2017-10-01 19:34:12 -04:00
Isiah Meadows
dbbdb0664a Reduce memory allocation/usage across multiple event handlers
- `handleEvent` is a very useful tool.
- Always use `addEventListener`/`removeEventListener`, since it's
  required for this optimization.
- Change log updated.
- Drive-by: make DOM mock work with both event listener types.
- Drive-by: eliminate possibility of `Object.prototype` interference.
2017-08-25 05:19:30 -04:00
tkilliansc
b4856a9ecd fix issue 1919 2017-08-03 13:48:19 -07:00
Pierre-Yves Gérardy
0e0ed7c45d Lint 2017-06-14 00:15:08 +02:00
Pierre-Yves Gérardy
47d59ea68a [test-utils] Make throttleMock more reliable 2017-06-13 23:30:12 +02:00
Pierre-Yves Gerardy
b004c20f0c Make m.redraw() strictly asynchronous 2017-06-13 15:20:29 +02:00
Pierre-Yves Gérardy
894152440b Add tests for #1870 2017-06-12 18:26:45 +02:00
Pierre-Yves Gerardy
195263d226 [test-utils/domMock] restore Attr.nodeValue for backwards compatibility 2017-05-29 13:59:31 +02:00
Pierre-Yves Gerardy
58bc414635 tests for validating #1595 and #1804 2017-05-28 21:03:27 +02:00
Pierre-Yves Gerardy
e031fe49a1 [test-utils/domMock] improve attributes handling 2017-05-28 18:26:09 +02:00
Pat Cavit
9a55a290cc feat: perf testing (#1789) 2017-04-13 09:48:30 -07:00
Pierre-Yves Gerardy
d0ee256390 [mocks] make location.onhashchange debounced async 2017-04-01 16:48:22 +02:00
Gyandeep Singh
daf5a64697 Chore: Fix lint issues and add indent with tabs 2017-03-11 15:54:41 -06:00
Isiah Meadows
1cc5fa5ba7 "use strict" and other linty fixes 2017-03-03 18:24:38 -05:00
Isiah Meadows
aefee3b88e Merge branch 'test-all-component-kinds' of https://github.com/pygy/mithril.js into next 2017-02-25 23:00:20 -05:00
Pierre-Yves Gerardy
eccea68212 Add test-utils/components.js and its tests 2017-02-19 02:14:15 +01:00
Bryce Gibson
6a617aeb87 Add tests for abort functionality. 2017-02-12 16:38:45 +11:00