Commit graph

184 commits

Author SHA1 Message Date
Stephan Hoyer
ab4b21dacc Make sure title attrs are removed properly - fixes #2676 2022-01-26 09:57:41 +01:00
Barney Carroll
ade77f37c9
Remove unreachable keyed node logic, fixes #2597 (#2673) 2021-04-18 18:14:21 +01: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
ZeikJT
cf7a841c4c
Remove extra isLifecycleMethod call from removeAttr (#2594) 2020-05-17 00:50:16 -07:00
Tim Gates
11e8e861fc
docs: Fix simple typo, subsequece -> subsequence (#2582)
There is a small typo in mithril.js, render/render.js.

Should read `subsequence` rather than `subsequece`.
2020-04-08 12:07:28 -07: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
30ad45caa1
Unbreak m.trust (#2516)
* Actually return the check from `maybeSetContentEditable`

Lots of code paths relied on it being a boolean. When I created the
abstraction, I apparently forgot to make sure it returned the result.

* Don't forget to copy instance state over

* Update changelog [skip ci]

* Fix changelog issue [skip ci]
2019-08-17 14:38:10 -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
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
db277217f8
Move fragment type check to normalizer (#2462)
Should result in more informative stack traces.

Fixes #2461
2019-07-07 17:16:56 -04:00
Isiah Meadows
6c562d2b9b
Fix keys, normalize holes (#2452)
* Fix #2434

* Treat holes as unkeyed, normalize boolean/null/undefined

This brings a lot better consistency with that API, even though it's
slightly breaking. (I had to update a bunch of tests to correspond with
it.)

* Fill in PR number [skip ci]
2019-07-03 17:05:44 -04:00
Isiah Meadows
ddc8adbbd3
Fix #2424 (#2450)
* Fix #2424

* Add PR ref
2019-07-03 14:41:37 -04:00
Isiah Meadows
9e9b89d900
Fix #2067 (#2447)
* Fix #2067

* Add PR number [skip ci]
2019-07-03 04:53:45 -04:00
Isiah Meadows
8134c51a48
Fix style updates to avoid unnecessary allocation (#2312)
* Fix style updates to avoid unnecessary allocation

- Drive-by: properly censor `cssFloat` -> css `float:` to match DOM
  behavior

* Document `style` syntax + custom property support. [skip ci]

* Add a missing test

* Add a few more descriptive comments.

* Update changelog [skip ci]
2018-12-03 14:31:08 -05:00
Isiah Meadows
462fb659d7
Fix event handler this value, simplify redraw handling (#2320)
Shaves 10 bytes off the bundle from smaller name + reduced indirection
2018-12-03 06:35:27 -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
Isiah Meadows
a8473e63c9
Reverse hook order for all but onbeforeupdate (#2297)
- Drive-by: `onbeforeupdate` prevents subtree redraw if *either* hook
  returns `false`, not *both*.
2018-11-27 18:02:48 -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
Pierre-Yves Gérardy
d6489e3b3f Merge #2075 into next (#2175)
* fix: Access document.activeElement through a function that eats errors for IE (#2075)

* test: inline iframe.js so ospec doesn't try to run it
2018-11-07 18:42:50 -05:00
spacejack
ea0ce7f762 Store normalized vnodes in the dom element. Add render tests. (#2266)
* Store normalized vnodes in the dom element. Add render tests.

* Add entry to change-log
2018-10-28 17:17:24 -04:00
Isiah Meadows
88b17c1c60
Avoid triggering Object.prototype.__proto__ with keys (#2251)
This way, the diff algorithm works with untrusted keys.
2018-10-15 15:09:55 -04:00
Isiah Meadows
62eb081a13 Simplify element removal to save a few bytes
It's also a minor peephole optimization, but I saw bigger size wins, so
I'm citing that.
2018-09-22 12:02:58 -04:00
Isiah Meadows
1ecc30a064 Fix custom elements attribute application, improve key checking
- Fix custom elements attribute application to acknowledge that not all
  custom elements operate purely based on attributes. (Plus, those
  blasted things are verbose as heck when you're working with them in
  raw form. It's also not that uncommon for functionality to be exposed
  via property and *not* attribute.)
- Don't memoize the normalized value when we 1. only use it once in each
  branch, and 2. only use it for a few special cases.
- Centralize the "has property key" code, so it's easier to tune and
  read. I also inlined a couple functions while I was at it since they
  were small and only used once.
- Actually test for how attributes are applied to raw DOM elements vs
  when we choose to use keys. When I first developed the patch, it
  silently worked, when I should've been breaking things.
2018-09-20 15:08:49 -04:00
Isiah Meadows
ad5118165c
Fix redundancy (#2213)
* Remove redundant empty fragment return

* Rebuild bundles

* Update changelog
2018-09-19 01:23:33 -04: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
Sebastian Sandqvist
571b60830b [render/render] Prevent activeElement.focus on SVGs, fix #1983 2018-06-11 22:04:34 +02:00
Pierre-Yves Gérardy
3f5cabc5c5 Chore: Normalize the way we use eslint-disable 2018-06-01 21:27:02 +02:00
Pierre-Yves Gérardy
cfa128a5cd [render/render] make updateAttrs smarter about null values 2018-06-01 21:27:02 +02:00
Pierre-Yves Gérardy
4921083898 [render/render] Fix xlink:href handling 2018-06-01 21:27:02 +02:00
Pierre-Yves Gerardy
5b51b682ee Improve attrs removal, fix #1804 2018-06-01 21:27:02 +02:00
Pierre-Yves Gerardy
dc15acd791 Improve attrs setting performance
before:

> mutate styles/properties x 7,999 ops/sec ±10.87% (46 runs sampled)

after:

> mutate styles/properties x 16,104 ops/sec ±4.36% (66 runs sampled)
2018-06-01 21:27:02 +02:00
Pierre-Yves Gerardy
4197cf0ae1 Enable the tests for #1804 2018-06-01 21:27:02 +02:00
Pierre-Yves Gérardy
285cb5382f [render] cleanup and comments 2018-05-29 23:50:29 +02:00
Pierre-Yves Gérardy
144ce68192 [render/render] get rid of vnode.skip 2018-05-29 23:50:29 +02:00
Pierre-Yves Gérardy
2cfc68359d [render/render] Introduce longest increasing subsequence-based node moves in keyed diff, fix #1791, fix #2026 2018-05-29 23:50:29 +02:00
Pierre-Yves Gérardy
44e165a357 [render/render] Misc comment fixes 2018-04-23 13:52:03 +02:00
Pierre-Yves Gérardy
f7a95d8c12 Cleanup, comments, and optimize getKeyMap 2018-04-23 13:52:03 +02:00
Pierre-Yves Gérardy
801bde219e [render/render] move keyed cached nodes when needed, fix diff semantics for cached nodes, fix #2132 2018-04-23 13:52:03 +02:00
Pierre-Yves Gérardy
9490950c30 [render/render] Simplify updateNodes, fix #2128 2018-04-23 13:52:03 +02:00
Pierre-Yves Gérardy
c6693aa361 Disentangle keyed and unkeyed diff 2018-04-23 13:52:03 +02:00
Pierre-Yves Gérardy
203df39c30 Remove the DOM nodes recycling pool (fix #1653, fix #2023) 2018-04-16 09:45:45 +02:00
Pierre-Yves Gérardy
d21ba5ee6a Document the reason for the possibleParents map 2018-03-06 02:13:15 +01:00
Pierre-Yves Gérardy
ad46a21a7d [render] add support for SVG in m.trust() strings 2018-03-06 01:12:32 +01:00
Fabiano Taioli
83884bdc90 element value is not cleared when value valor change to undefined 2018-02-09 00:47:59 +01:00
Pierre-Yves Gérardy
1782fa8b63 render: fix perf regression introduced by #1918 2017-12-08 21:37:08 +01:00
Pierre-Yves Gérardy
9f09ac069c Address #2021 review comments 2017-12-04 14:38:39 +01:00