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

Release - v3.0.0 #2776

Merged
merged 22 commits into from
Jan 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/auto-merge.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
name: auto-merge

on:
pull_request:
pull_request_target:
branches: [ next ]

jobs:
auto-merge:
runs-on: ubuntu-latest
if: github.actor == 'dependabot[bot]'
steps:
- uses: actions/checkout@v3
- uses: ahmadnassri/action-dependabot-auto-merge@v2
Expand Down
30 changes: 30 additions & 0 deletions .github/workflows/lint-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: lint-docs

on:
push:
branches: [ next ]
pull_request:
branches: [ next ]

jobs:
lint-docs:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [18]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm ci
- run: npm run lint:docs
30 changes: 30 additions & 0 deletions .github/workflows/lint-js.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: lint-js

on:
push:
branches: [ next ]
pull_request:
branches: [ next ]

jobs:
lint-js:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [18]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm ci
- run: npm run lint:js
2 changes: 1 addition & 1 deletion .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@ jobs:
name: Setup NPM Auth
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- run: npx pr-release infer-prerelease --preid=next --verbose --publish --minimize-semver-change
- run: npx pr-release infer-prerelease --preid=next --target master --source next --verbose --publish --minimize-semver-change
name: Publish
30 changes: 30 additions & 0 deletions .github/workflows/test-js.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: test-js

on:
push:
branches: [ next ]
pull_request:
branches: [ next ]

jobs:
test-js:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [14, 16, 18]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm ci
- run: npm run test:js
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

## What is Mithril.js?

A modern client-side JavaScript framework for building Single Page Applications. It's small (<!-- size -->10.05 KB<!-- /size --> gzipped), fast and provides routing and XHR utilities out of the box.
A modern client-side JavaScript framework for building Single Page Applications. It's small (<!-- size -->9.14 KB<!-- /size --> gzipped), fast and provides routing and XHR utilities out of the box.

Mithril.js is used by companies like Vimeo and Nike, and open source platforms like Lichess 👍.

Expand Down
1 change: 0 additions & 1 deletion api/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

var Vnode = require("../render/vnode")
var m = require("../render/hyperscript")
var Promise = require("../promise/promise")

var buildPathname = require("../pathname/build")
var parsePathname = require("../pathname/parse")
Expand Down
18 changes: 17 additions & 1 deletion api/tests/test-router.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ var m = require("../../render/hyperscript")
var coreRenderer = require("../../render/render")
var apiMountRedraw = require("../../api/mount-redraw")
var apiRouter = require("../../api/router")
var Promise = require("../../promise/promise")

o.spec("route", function() {
// Note: the `n` parameter used in calls to this are generally found by
Expand Down Expand Up @@ -209,6 +208,23 @@ o.spec("route", function() {
)
})

o("keeps trailing / in rest parameterized route", function() {
$window.location.href = prefix + "/test/d/"
route(root, "/test/:a...", {
"/test/:a..." : {
view: lock(function(vnode) {
return JSON.stringify(route.param()) + " " +
JSON.stringify(vnode.attrs) + " " +
route.get()
})
}
})

o(root.firstChild.nodeValue).equals(
'{"a":"d/"} {"a":"d/"} /test/d/'
)
})

o("handles route with search", function() {
$window.location.href = prefix + "/test?a=b&c=d"
route(root, "/test", {
Expand Down
2 changes: 1 addition & 1 deletion docs/animation.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ var FancyComponent = {

`vnode.dom` points to the root DOM element of the component (`<div class="fancy">`). We use the classList API here to add an `exit` class to `<div class="fancy">`.

Then we return a [Promise](promise.md) that resolves when the `animationend` event fires. When we return a promise from `onbeforeremove`, Mithril.js waits until the promise is resolved and only then it removes the element. In this case, it waits for the exit animation to finish.
Then we return a Promise that resolves when the `animationend` event fires. When we return a promise from `onbeforeremove`, Mithril.js waits until the promise is resolved and only then it removes the element. In this case, it waits for the exit animation to finish.

We can verify that both the enter and exit animations work by mounting the `Toggler` component:

Expand Down
15 changes: 0 additions & 15 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,21 +92,6 @@ m.request({

---

#### m.jsonp(options) - [docs](jsonp.md)

```javascript
m.jsonp({
url: "/api/v1/users/:id",
params: {id: 1},
callbackKey: "callback",
})
.then(function(result) {
console.log(result)
})
```

---

#### m.parseQueryString(querystring) - [docs](parseQueryString.md)

```javascript
Expand Down
2 changes: 1 addition & 1 deletion docs/buildPathname.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Argument | Type | Required | Descripti

### How it works

The `m.buildPathname` creates a [path name](paths.md) from a path template and a parameters object. It's useful for building URLs, and it's what [`m.route`](route.md), [`m.request`](request.md), and [`m.jsonp`](jsonp.md) all use internally to interpolate paths. It uses [`m.buildQueryString`](buildQueryString.md) to generate the query parameters to append to the path name.
The `m.buildPathname` creates a [path name](paths.md) from a path template and a parameters object. It's useful for building URLs, and it's what [`m.route`](route.md) and [`m.request`](request.md) use internally to interpolate paths. It uses [`m.buildQueryString`](buildQueryString.md) to generate the query parameters to append to the path name.

```javascript
var pathname = m.buildPathname("/path/:id", {id: "user", a: 1, b: 2})
Expand Down
6 changes: 2 additions & 4 deletions docs/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,17 @@ To send a pull request:

## I'm submitting a PR. How do I run tests?

Assuming you have forked this repo, you can open the `index.html` file in a module's `tests` folder and look at console output to see only tests for that module, or you can run `ospec/bin/ospec` from the command line to run all tests.
After having run `npm install` (a one-time operation), run `npm run test` from the command line to run all tests.

While testing, you can modify a test to use `o.only(description, test)` instead of `o(description, test)` if you wish to run only a specific test to speed up your debugging experience. Don't forget to remove the `.only` after you're done!

There is no need to `npm install` anything in order to run the test suite, however NodeJS is required to run the test suite from the command line. You do need to `npm install` if you want to lint or get a code coverage report though.



## How do I build Mithril.js?

If all you're trying to do is run examples in the codebase, you don't need to build Mithril.js, you can just open the various html files and things should just work.

To generate the bundled file for testing, run `npm run dev` from the command line. To generate the minified file, run `npm run build`. There is no need to `npm install` anything, but NodeJS is required to run the build scripts.
To generate the bundled file for testing, run `npm run dev` from the command line. To generate the minified file, run `npm run build`.



Expand Down
2 changes: 1 addition & 1 deletion docs/hyperscript.md
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ m("a-scene", [
])
```

And yes, this translates to both attributes and properties, and it works just like they would in the DOM. Using [Brick's `brick-deck`](http://brick.mozilla.io/docs/brick-deck) as an example, they have a `selected-index` attribute with a corresponding `selectedIndex` getter/setter property.
And yes, this translates to both attributes and properties, and it works just like they would in the DOM. Using Brick's `brick-deck` (DEAD LINK, FIXME: http //brick.mozilla.io/docs/brick-deck) as an example, they have a `selected-index` attribute with a corresponding `selectedIndex` getter/setter property.

```javascript
m("brick-deck[selected-index=0]", [/* ... */]) // lowercase
Expand Down
103 changes: 0 additions & 103 deletions docs/jsonp.md

This file was deleted.

4 changes: 2 additions & 2 deletions docs/jsx.md
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ You can use hooks in your production environment to run the production build scr

In order to access `m` globally from all your project first import `webpack` in your `webpack.config.js` like this:

```
```js
const webpack = require('webpack')
```

Expand Down Expand Up @@ -255,7 +255,7 @@ Similarly, React always uses the camel-cased style property names exposed in the

React upper-cases the first character of all event handlers: `onClick` listens for `click` events and `onSubmit` for `submit` events. Some are further altered as they're multiple words concatenated together. For instance, `onMouseMove` listens for `mousemove` events. Mithril does not do this case mapping but instead just prepends `on` to the native event, so you'd add listeners for `onclick` and `onmousemove` to listen to those two events respectively. This corresponds much more closely to HTML's naming scheme and is much more intuitive if you come from an HTML or vanilla DOM background.

React supports scheduling event listeners during the capture phase (in the first pass, out to in, as opposed to the default bubble phase going in to out in the second pass) by appending `Capture` to that event. Mithril currently lacks such functionality, but it could gain this in the future. If this is necessary you can manually add and remove your own listeners in [lifecycle hooks](lifecycle.md).
React supports scheduling event listeners during the capture phase (in the first pass, out to in, as opposed to the default bubble phase going in to out in the second pass) by appending `Capture` to that event. Mithril currently lacks such functionality, but it could gain this in the future. If this is necessary you can manually add and remove your own listeners in [lifecycle hooks](lifecycle-methods.md).

---

Expand Down
4 changes: 1 addition & 3 deletions docs/nav-methods.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,14 @@
- [m.mount](mount.md)
- [m.route](route.md)
- [m.request](request.md)
- [m.jsonp](jsonp.md)
- [m.parseQueryString](parseQueryString.md)
- [m.buildQueryString](buildQueryString.md)
- [m.buildPathname](buildPathname.md)
- [m.parsePathname](parsePathname.md)
- [m.trust](trust.md)
- [m.fragment](fragment.md)
- [m.redraw](redraw.md)
- [Promise](promise.md)
- Optional
- [Stream](stream.md)
- Tooling
- [Ospec](https://github.com/MithrilJS/mithril.js/blob/master/ospec)
- [Ospec](https://github.com/MithrilJS/ospec)
Loading