diff --git a/.babelrc b/.babelrc new file mode 100644 index 00000000..deef3397 --- /dev/null +++ b/.babelrc @@ -0,0 +1,3 @@ +// This is solely to avoid https://github.com/danger/danger-js/issues/261 +// and should be fine to remove before much longer +{} diff --git a/.eslintignore b/.eslintignore index 61d2a0b7..62117a94 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,7 +1,7 @@ -.vscode -/coverage -/docs/lib -/examples +.vscode/ +coverage/ +docs/lib/ +examples/ /mithril.js /mithril.min.js -/node_modules +node_modules/ diff --git a/.gitattributes b/.gitattributes index 6de5c647..7296866f 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,3 +1,5 @@ * text=auto /mithril.js binary /mithril.min.js binary +/package-lock.json binary +/yarn.lock binary diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 00000000..30c39524 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1,11 @@ +# Leo owns everything, for better or worse +* @lhorie + +.travis.yml @tivac +package.json @tivac +.npmignore @tivac +.eslintrc.js @tivac +.eslintignore @tivac +README.md @tivac +docs/ @tivac +performance/ @tivac diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md new file mode 100644 index 00000000..be4f8168 --- /dev/null +++ b/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,32 @@ + + +## Expected Behavior + + + +## Current Behavior + + + +## Possible Solution + + + +## Steps to Reproduce (for bugs) + + +1. +2. +3. +4. + +## Context + + + +## Your Environment + +* Version used: +* Browser Name and version: +* Operating System and version (desktop or mobile): +* Link to your project: diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 00000000..b60b2e54 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,30 @@ + + +## Description + + +## Motivation and Context + + + +## How Has This Been Tested? + + + + +## 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) + +## 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` diff --git a/.travis.yml b/.travis.yml index 75e9b45c..d4470ebd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,13 +13,20 @@ cache: # Custom install step so the travis-only stuff doesn't need to be in package.json install: - npm install -- npm install @alrra/travis-scripts@^3.0.1 gh-pages@^0.12.0 +# This is to prevent lint-staged/prettier from running on the bundles +- npm rm husky -# Bundle before running tests so the bundle is always up-to-date -before_script: npm run build +# Run danger, build bundles (so they're always up to date) +before_script: +- npx danger run +- npm run build-browser +# Pass -save so it'll update the readme as well +- npm run build-min -- -save -# This is the default, but leaving so it is obvious -# script: npm test +# Run tests, lint, and then check for perf regressions +script: +- npm test +- npm run perf # After a successful build commit changes back to repo after_success: @@ -42,7 +49,7 @@ after_success: # this doesn't have the built-in branch protection like commit-changes if [ "$TRAVIS_EVENT_TYPE" == "push" ] && \ [ "$TRAVIS_BRANCH" == "master" ] && \ - [ "$TRAVIS_REPO_SLUG" == "lhorie/mithril.js" ] + [ "$TRAVIS_REPO_SLUG" == "MithrilJS/mithril.js" ] then # Generate docs npm run gendocs @@ -57,7 +64,7 @@ after_success: $(npm bin)/gh-pages \ --dist ./dist \ --add \ - --repo "git@github.com:lhorie/mithril.js.git" \ + --repo "git@github.com:MithrilJS/mithril.js.git" \ --message "Generated docs for commit $TRAVIS_COMMIT [skip ci]" else echo "Not submitting documentation updates" @@ -81,8 +88,7 @@ deploy: skip_cleanup: true on: tags: true - repo: lhorie/mithril.js - branch: master + repo: MithrilJS/mithril.js - provider: npm skip_cleanup: true @@ -91,5 +97,4 @@ deploy: secure: ADElvD1oxn9GfEG7dDOggX96b36A/cGEybovAc0221CCKzv5kWCavMrtxneiJYI6N/n24abSlbM90vMfU84FEzH0Ev28dGVokRP4ad6VRkISszKlYVEP8Lds4QxfKh78jZlUxmxM0B3vmQ1kYJbTBqp3ICtaJ5ptEQHWhrLtxnc= on: tags: true - repo: lhorie/mithril.js - branch: master + repo: MithrilJS/mithril.js diff --git a/README.md b/README.md index 08636be2..4638fa31 100644 --- a/README.md +++ b/README.md @@ -1,267 +1,61 @@ -# Introduction +mithril.js [](https://www.npmjs.com/package/mithril) [](https://www.npmjs.com/package/mithril) [](https://www.npmjs.com/package/mithril) +========== + +
- [What is Mithril?](#what-is-mithril) -- [Getting started](#getting-started) -- [Hello world](#hello-world) -- [DOM elements](#dom-elements) -- [Components](#components) -- [Routing](#routing) -- [XHR](#xhr) +- [Installation](#installation) +- [Documentation](#documentation) +- [Getting Help](#getting-help) +- [Contributing](#contributing) + +## What is Mithril? + +A modern client-side Javascript framework for building Single Page Applications. It's small (8.22 KB gzipped), fast and provides routing and XHR utilities out of the box. + +Mithril is used by companies like Vimeo and Nike, and open source platforms like Lichess 👍. + +Browsers all the way back to IE9 are supported, no polyfills required 👌. + +## Installation + +### CDN + +```html + +``` + +### npm + +```bash +$ npm install mithril +``` + +The ["Getting started" guide](https://mithril.js.org/#getting-started) is a good place to start learning how to use mithril. + +## Documentation + +Documentation lives on [mithril.js.org](https://mithril.js.org). + +You may be interested in the [API Docs](https://mithril.js.org/api.html), a [Simple Application](https://mithril.js.org/simple-application.html), or perhaps some [Examples](https://mithril.js.org/examples.html). + +## Getting Help + +Mithril has an active & welcoming community on [Gitter](https://gitter.im/mithriljs/mithril.js), or feel free to ask questions on [Stack Overflow](https://stackoverflow.com/questions/tagged/mithril.js) using the `mithril.js` tag. + +## Contributing + +There's a [Contributing FAQ](https://mithril.js.org/contributing.html) on the mithril site that hopefully helps, but if not definitely hop into the [Gitter Room](https://gitter.im/mithriljs/mithril.js) and ask away! --- -### What is Mithril? +Thanks for reading! -Mithril is a modern client-side Javascript framework for building Single Page Applications. -It's small (< 8kb gzip), fast and provides routing and XHR utilities out of the box. - -
+ ${pinpoint(code, {line: loc.line, column : loc.cursor})}
+
+ `))
+ )
+ });
diff --git a/docs/change-log.md b/docs/change-log.md
index 2d3b03fe..cb2fabf0 100644
--- a/docs/change-log.md
+++ b/docs/change-log.md
@@ -1,5 +1,7 @@
# Change log
+- [v1.1.3](#v113)
+- [v1.1.2](#v112)
- [v1.1.1](#v111)
- [v1.1.0](#v110)
- [v1.0.1](#v101)
@@ -8,14 +10,69 @@
---
+### v2.0.0 (WIP)
+
+#### Breaking changes
+
+- API: `m.redraw()` is always asynchronous ([#1592](https://github.com/MithrilJS/mithril.js/pull/1592))
+- API: `m.mount()` will only render its own root when called, it will not trigger a `redraw()` ([#1592](https://github.com/MithrilJS/mithril.js/pull/1592))
+
+#### News
+
+- API: Introduction of `m.redraw.sync()` ([#1592](https://github.com/MithrilJS/mithril.js/pull/1592))
+
+#### Bug fixes
+
+- API: `m.route.set()` causes all mount points to be redrawn ([#1592](https://github.com/MithrilJS/mithril.js/pull/1592))
+
+---
+
+### v1.1.3
+
+#### Bug fixes:
+
+- move out npm dependencies added by mistake
+
+---
+
+### v1.1.2
+
+#### Bug fixes:
+
+- core: Namespace fixes [#1819](https://github.com/MithrilJS/mithril.js/issues/1819), ([#1825](https://github.com/MithrilJS/mithril.js/pull/1825) [@SamuelTilly](https://github.com/SamuelTilly)), [#1820](https://github.com/MithrilJS/mithril.js/issues/1820) ([#1864](https://github.com/MithrilJS/mithril.js/pull/1864)), [#1872](https://github.com/MithrilJS/mithril.js/issues/1872) ([#1873](https://github.com/MithrilJS/mithril.js/pull/1873))
+- core: Fix select option to allow empty string value [#1814](https://github.com/MithrilJS/mithril.js/issues/1814) ([#1828](https://github.com/MithrilJS/mithril.js/pull/1828) [@spacejack](https://github.com/spacejack))
+- core: Reset e.redraw when it was set to `false` [#1850](https://github.com/MithrilJS/mithril.js/issues/1850) ([#1890](https://github.com/MithrilJS/mithril.js/pull/1890))
+- core: differentiate between `{ value: "" }` and `{ value: 0 }` for form elements [#1595 comment](https://github.com/MithrilJS/mithril.js/pull/1595#issuecomment-304071453) ([#1862](https://github.com/MithrilJS/mithril.js/pull/1862))
+- core: Don't reset the cursor of textareas in IE10 when setting an identical `value` [#1870](https://github.com/MithrilJS/mithril.js/issues/1870) ([#1871](https://github.com/MithrilJS/mithril.js/pull/1871))
+- hypertext: Correct handling of `[value=""]` ([#1843](https://github.com/MithrilJS/mithril.js/issues/1843), [@CreaturesInUnitards](https://github.com/CreaturesInUnitards))
+- router: Don't overwrite the options object when redirecting from `onmatch with m.route.set()` [#1857](https://github.com/MithrilJS/mithril.js/issues/1857) ([#1889](https://github.com/MithrilJS/mithril.js/pull/1889))
+- stream: Move the "use strict" directive inside the IIFE [#1831](https://github.com/MithrilJS/mithril.js/issues/1831) ([#1893](https://github.com/MithrilJS/mithril.js/pull/1893))
+
+#### Ospec improvements:
+
+- Shell command: Ignore hidden directories and files ([#1855](https://github.com/MithrilJS/mithril.js/pull/1855) [@pdfernhout)](https://github.com/pdfernhout))
+- Library: Add the possibility to name new test suites ([#1529](https://github.com/MithrilJS/mithril.js/pull/1529))
+
+#### Docs / Repo maintenance:
+
+Our thanks to [@0joshuaolson1](https://github.com/0joshuaolson1), [@ACXgit](https://github.com/ACXgit), [@cavemansspa](https://github.com/cavemansspa), [@CreaturesInUnitards](https://github.com/CreaturesInUnitards), [@dlepaux](https://github.com/dlepaux), [@isaaclyman](https://github.com/isaaclyman), [@kevinkace](https://github.com/kevinkace), [@micellius](https://github.com/micellius), [@spacejack](https://github.com/spacejack) and [@yurivish](https://github.com/yurivish)
+
+#### Other:
+
+- Addition of a performance regression test suite ([#1789](https://github.com/MithrilJS/mithril.js/issues/1789))
+
+---
+
### v1.1.1
#### Bug fixes
-- hyperscript: Allow `0` as the second argument to `m()` - [#1752](https://github.com/lhorie/mithril.js/issues/#1752) / [#1753](https://github.com/lhorie/mithril.js/pull/#1753) ([@StephanHoyer](https://github.com/StephanHoyer))
-- hyperscript: remove `attrs.class` after normalizing to `attrs.className` - [#1764](https://github.com/lhorie/mithril.js/issues/#1764) / [#1769](https://github.com/lhorie/mithril.js/pull/#1769)
+- hyperscript: Allow `0` as the second argument to `m()` - [#1752](https://github.com/MithrilJS/mithril.js/issues/1752) / [#1753](https://github.com/MithrilJS/mithril.js/pull/1753) ([@StephanHoyer](https://github.com/StephanHoyer))
+- hyperscript: restore `attrs.class` handling to what it was in v1.0.1 - [#1764](https://github.com/MithrilJS/mithril.js/issues/1764) / [#1769](https://github.com/MithrilJS/mithril.js/pull/1769)
- documentation improvements ([@JAForbes](https://github.com/JAForbes), [@smuemd](https://github.com/smuemd), [@hankeypancake](https://github.com/hankeypancake))
+---
+
### v1.1.0
#### News
@@ -26,10 +83,10 @@
#### Bug fixes
-- fix IE11 input[type] error - [#1610](https://github.com/lhorie/mithril.js/issues/1610)
-- apply [#1609](https://github.com/lhorie/mithril.js/issues/1609) to unkeyed children case
-- fix abort detection [#1612](https://github.com/lhorie/mithril.js/issues/1612)
-- fix input value focus issue when value is loosely equal to old value [#1593](https://github.com/lhorie/mithril.js/issues/1593)
+- fix IE11 input[type] error - [#1610](https://github.com/MithrilJS/mithril.js/issues/1610)
+- apply [#1609](https://github.com/MithrilJS/mithril.js/issues/1609) to unkeyed children case
+- fix abort detection [#1612](https://github.com/MithrilJS/mithril.js/issues/1612)
+- fix input value focus issue when value is loosely equal to old value [#1593](https://github.com/MithrilJS/mithril.js/issues/1593)
---
@@ -37,12 +94,12 @@
#### News
-- performance improvements in IE [#1598](https://github.com/lhorie/mithril.js/pull/1598)
+- performance improvements in IE [#1598](https://github.com/MithrilJS/mithril.js/pull/1598)
#### Bug fixes
-- prevent infinite loop in non-existent default route - [#1579](https://github.com/lhorie/mithril.js/issues/1579)
-- call correct lifecycle methods on children of recycled keyed vnodes - [#1609](https://github.com/lhorie/mithril.js/issues/1609)
+- prevent infinite loop in non-existent default route - [#1579](https://github.com/MithrilJS/mithril.js/issues/1579)
+- call correct lifecycle methods on children of recycled keyed vnodes - [#1609](https://github.com/MithrilJS/mithril.js/issues/1609)
---
@@ -155,7 +212,7 @@ m("div", {
// Called after the node is updated
onupdate : function(vnode) { /*...*/ },
// Called before the node is removed, return a Promise that resolves when
- // ready for the node to be removed from the DOM
+ // ready for the node to be removed from the DOM
onbeforeremove : function(vnode) { /*...*/ },
// Called before the node is removed, but after onbeforeremove calls done()
onremove : function(vnode) { /*...*/ }
@@ -472,9 +529,9 @@ In `v0.2.x` reading route params was entirely handled through `m.route.param()`.
```javascript
m.route(document.body, "/booga", {
"/:attr" : {
- controller : function() {
- m.route.param("attr") // "booga"
- },
+ controller : function() {
+ m.route.param("attr") // "booga"
+ },
view : function() {
m.route.param("attr") // "booga"
}
@@ -489,11 +546,11 @@ m.route(document.body, "/booga", {
"/:attr" : {
oninit : function(vnode) {
vnode.attrs.attr // "booga"
- m.route.param("attr") // "booga"
+ m.route.param("attr") // "booga"
},
view : function(vnode) {
vnode.attrs.attr // "booga"
- m.route.param("attr") // "booga"
+ m.route.param("attr") // "booga"
}
}
})
@@ -531,14 +588,14 @@ It is no longer possible to prevent unmounting via `onunload`'s `e.preventDefaul
```javascript
var Component = {
- controller: function() {
- this.onunload = function(e) {
- if (condition) e.preventDefault()
- }
- },
- view: function() {
- return m("a[href=/]", {config: m.route})
- }
+ controller: function() {
+ this.onunload = function(e) {
+ if (condition) e.preventDefault()
+ }
+ },
+ view: function() {
+ return m("a[href=/]", {config: m.route})
+ }
}
```
@@ -546,9 +603,9 @@ var Component = {
```javascript
var Component = {
- view: function() {
- return m("a", {onclick: function() {if (!condition) m.route.set("/")}})
- }
+ view: function() {
+ return m("a", {onclick: function() {if (!condition) m.route.set("/")}})
+ }
}
```
@@ -562,14 +619,14 @@ Components no longer call `this.onunload` when they are being removed. They now
```javascript
var Component = {
- controller: function() {
- this.onunload = function(e) {
- // ...
- }
- },
- view: function() {
- // ...
- }
+ controller: function() {
+ this.onunload = function(e) {
+ // ...
+ }
+ },
+ view: function() {
+ // ...
+ }
}
```
@@ -577,12 +634,12 @@ var Component = {
```javascript
var Component = {
- onremove : function() {
- // ...
- }
- view: function() {
- // ...
- }
+ onremove : function() {
+ // ...
+ }
+ view: function() {
+ // ...
+ }
}
```
@@ -598,13 +655,13 @@ In addition, requests no longer have `m.startComputation`/`m.endComputation` sem
```javascript
var data = m.request({
- method: "GET",
- url: "https://api.github.com/",
- initialValue: [],
+ method: "GET",
+ url: "https://api.github.com/",
+ initialValue: [],
})
setTimeout(function() {
- console.log(data())
+ console.log(data())
}, 1000)
```
@@ -613,15 +670,15 @@ setTimeout(function() {
```javascript
var data = []
m.request({
- method: "GET",
- url: "https://api.github.com/",
+ method: "GET",
+ url: "https://api.github.com/",
})
.then(function (responseBody) {
- data = responseBody
+ data = responseBody
})
setTimeout(function() {
- console.log(data) // note: not a getter-setter
+ console.log(data) // note: not a getter-setter
}, 1000)
```
@@ -653,11 +710,11 @@ greetAsync()
```javascript
var greetAsync = function() {
- return new Promise(function(resolve){
- setTimeout(function() {
- resolve("hello")
- }, 1000)
- })
+ return new Promise(function(resolve){
+ setTimeout(function() {
+ resolve("hello")
+ }, 1000)
+ })
}
greetAsync()
@@ -679,7 +736,7 @@ m.sync([
m.request({ method: 'GET', url: 'https://api.github.com/users/isiahmeadows' }),
])
.then(function (users) {
- console.log("Contributors:", users[0].name, "and", users[1].name)
+ console.log("Contributors:", users[0].name, "and", users[1].name)
})
```
@@ -691,7 +748,7 @@ Promise.all([
m.request({ method: 'GET', url: 'https://api.github.com/users/isiahmeadows' }),
])
.then(function (users) {
- console.log("Contributors:", users[0].name, "and", users[1].name)
+ console.log("Contributors:", users[0].name, "and", users[1].name)
})
```
@@ -706,7 +763,7 @@ In `v0.2.x`, the `xlink` namespace was the only supported attribute namespace, a
```javascript
m("svg",
// the `href` attribute is namespaced automatically
- m("image[href='image.gif']")
+ m("image[href='image.gif']")
)
```
@@ -715,7 +772,7 @@ m("svg",
```javascript
m("svg",
// User-specified namespace on the `href` attribute
- m("image[xlink:href='image.gif']")
+ m("image[xlink:href='image.gif']")
)
```
diff --git a/docs/code-of-conduct.md b/docs/code-of-conduct.md
new file mode 100644
index 00000000..50ebe61d
--- /dev/null
+++ b/docs/code-of-conduct.md
@@ -0,0 +1,74 @@
+# Contributor Covenant Code of Conduct
+
+## Our Pledge
+
+In the interest of fostering an open and welcoming environment, we as
+contributors and maintainers pledge to making participation in our project and
+our community a harassment-free experience for everyone, regardless of age, body
+size, disability, ethnicity, gender identity and expression, level of experience,
+nationality, personal appearance, race, religion, or sexual identity and
+orientation.
+
+## Our Standards
+
+Examples of behavior that contributes to creating a positive environment
+include:
+
+* Using welcoming and inclusive language
+* Being respectful of differing viewpoints and experiences
+* Gracefully accepting constructive criticism
+* Focusing on what is best for the community
+* Showing empathy towards other community members
+
+Examples of unacceptable behavior by participants include:
+
+* The use of sexualized language or imagery and unwelcome sexual attention or
+advances
+* Trolling, insulting/derogatory comments, and personal or political attacks
+* Public or private harassment
+* Publishing others' private information, such as a physical or electronic
+ address, without explicit permission
+* Other conduct which could reasonably be considered inappropriate in a
+ professional setting
+
+## Our Responsibilities
+
+Project maintainers are responsible for clarifying the standards of acceptable
+behavior and are expected to take appropriate and fair corrective action in
+response to any instances of unacceptable behavior.
+
+Project maintainers have the right and responsibility to remove, edit, or
+reject comments, commits, code, wiki edits, issues, and other contributions
+that are not aligned to this Code of Conduct, or to ban temporarily or
+permanently any contributor for other behaviors that they deem inappropriate,
+threatening, offensive, or harmful.
+
+## Scope
+
+This Code of Conduct applies both within project spaces and in public spaces
+when an individual is representing the project or its community. Examples of
+representing a project or community include using an official project e-mail
+address, posting via an official social media account, or acting as an appointed
+representative at an online or offline event. Representation of a project may be
+further defined and clarified by project maintainers.
+
+## Enforcement
+
+Instances of abusive, harassing, or otherwise unacceptable behavior may be
+reported by contacting the project team at [github@patcavit.com](mailto:github@patcavit.com?subject=Mithril Code of Conduct). All
+complaints will be reviewed and investigated and will result in a response that
+is deemed necessary and appropriate to the circumstances. The project team is
+obligated to maintain confidentiality with regard to the reporter of an incident.
+Further details of specific enforcement policies may be posted separately.
+
+Project maintainers who do not follow or enforce the Code of Conduct in good
+faith may face temporary or permanent repercussions as determined by other
+members of the project's leadership.
+
+## Attribution
+
+This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
+available at [http://contributor-covenant.org/version/1/4][version]
+
+[homepage]: http://contributor-covenant.org
+[version]: http://contributor-covenant.org/version/1/4/
diff --git a/docs/components.md b/docs/components.md
index 229f1293..4df9dfe4 100644
--- a/docs/components.md
+++ b/docs/components.md
@@ -316,7 +316,7 @@ var Login = {
Normally, in the context of a larger application, a login component like the one above exists alongside components for user registration and password recovery. Imagine that we want to be able to prepopulate the email field when navigating from the login screen to the registration or password recovery screens (or vice versa), so that the user doesn't need to re-type their email if they happened to fill the wrong page (or maybe you want to bump the user to the registration form if a username is not found).
-Right away, we see that sharing the `username` and `password` fields from this component to another is difficult. This is because the fat component encapsulates its our state, which by definition makes this state difficult to access from outside.
+Right away, we see that sharing the `username` and `password` fields from this component to another is difficult. This is because the fat component encapsulates its state, which by definition makes this state difficult to access from outside.
It makes more sense to refactor this component and pull the state code out of the component and into the application's data layer. This can be as simple as creating a new module:
diff --git a/docs/contributing.md b/docs/contributing.md
index 5b4770d3..189d0b99 100644
--- a/docs/contributing.md
+++ b/docs/contributing.md
@@ -4,7 +4,7 @@
## How do I go about contributing ideas or new features?
-Create an [issue thread on Github](https://github.com/lhorie/mithril.js/issues/new) to suggest your idea so the community can discuss it.
+Create an [issue thread on GitHub](https://github.com/MithrilJS/mithril.js/issues/new) to suggest your idea so the community can discuss it.
If the consensus is that it's a good idea, the fastest way to get it into a release is to send a pull request. Without a PR, the time to implement the feature will depend on the bandwidth of the development team and its list of priorities.
@@ -20,12 +20,12 @@ Ideally, the best way to report bugs is to provide a small snippet of code where
To send a pull request:
-- fork the repo (button at the top right in Github)
-- clone the forked repo to your computer (green button in Github)
+- fork the repo (button at the top right in GitHub)
+- clone the forked repo to your computer (green button in GitHub)
- create a feature branch (run `git checkout -b the-feature-branch-name`)
- make your changes
- run the tests (run `npm t`)
-- submit a pull request (go to the pull requests tab in Github, click the green button and select your feature branch)
+- submit a pull request (go to the pull requests tab in GitHub, click the green button and select your feature branch)
diff --git a/docs/es6.md b/docs/es6.md
index 3c19613f..0192a6ca 100644
--- a/docs/es6.md
+++ b/docs/es6.md
@@ -5,7 +5,7 @@
---
-Mithril is written in ES5, and is fully compatible with ES6 as well. ES6 is a recent update to Javascript that introduces new syntax sugar for various common cases. It's not yet fully supported by all major browsers and it's not a requirement for writing application, but it may be pleasing to use depending on your team's preferences.
+Mithril is written in ES5, and is fully compatible with ES6 as well. ES6 is a recent update to Javascript that introduces new syntax sugar for various common cases. It's not yet fully supported by all major browsers and it's not a requirement for writing an application, but it may be pleasing to use depending on your team's preferences.
In some limited environments, it's possible to use a significant subset of ES6 directly without extra tooling (for example, in internal applications that do not support IE). However, for the vast majority of use cases, a compiler toolchain like [Babel](https://babeljs.io) is required to compile ES6 features down to ES5.
@@ -70,10 +70,12 @@ Create a `.babelrc` file:
Next, create a file called `webpack.config.js`
```javascript
+const path = require('path')
+
module.exports = {
entry: './src/index.js',
output: {
- path: './bin',
+ path: path.resolve(__dirname, './bin'),
filename: 'app.js',
},
module: {
diff --git a/docs/examples.md b/docs/examples.md
index 140ad3f6..749900cc 100644
--- a/docs/examples.md
+++ b/docs/examples.md
@@ -2,10 +2,10 @@
Here are some examples of Mithril in action
-- [Animation](http://cdn.rawgit.com/lhorie/mithril.js/rewrite/examples/animation/mosaic.html)
-- [DBMonster](http://cdn.rawgit.com/lhorie/mithril.js/rewrite/examples/dbmonster/mithril/index.html)
-- [Markdown Editor](http://cdn.rawgit.com/lhorie/mithril.js/rewrite/examples/editor/index.html)
-- SVG: [Clock](http://cdn.rawgit.com/lhorie/mithril.js/rewrite/examples/svg/clock.html), [Ring](http://cdn.rawgit.com/lhorie/mithril.js/rewrite/examples/svg/ring.html), [Tiger](http://cdn.rawgit.com/lhorie/mithril.js/rewrite/examples/svg/tiger.html)
-- [ThreadItJS](http://cdn.rawgit.com/lhorie/mithril.js/rewrite/examples/threaditjs/index.html)
-- [TodoMVC](http://cdn.rawgit.com/lhorie/mithril.js/rewrite/examples/todomvc/index.html)
+- [Animation](http://cdn.rawgit.com/MithrilJS/mithril.js/master/examples/animation/mosaic.html)
+- [DBMonster](http://cdn.rawgit.com/MithrilJS/mithril.js/master/examples/dbmonster/mithril/index.html)
+- [Markdown Editor](http://cdn.rawgit.com/MithrilJS/mithril.js/master/examples/editor/index.html)
+- SVG: [Clock](http://cdn.rawgit.com/MithrilJS/mithril.js/master/examples/svg/clock.html), [Ring](http://cdn.rawgit.com/MithrilJS/mithril.js/master/examples/svg/ring.html), [Tiger](http://cdn.rawgit.com/MithrilJS/mithril.js/master/examples/svg/tiger.html)
+- [ThreadItJS](http://cdn.rawgit.com/MithrilJS/mithril.js/master/examples/threaditjs/index.html)
+- [TodoMVC](http://cdn.rawgit.com/MithrilJS/mithril.js/master/examples/todomvc/index.html)
diff --git a/docs/favicon.ico b/docs/favicon.ico
new file mode 100644
index 00000000..61807fae
Binary files /dev/null and b/docs/favicon.ico differ
diff --git a/docs/favicon.png b/docs/favicon.png
new file mode 100644
index 00000000..50712630
Binary files /dev/null and b/docs/favicon.png differ
diff --git a/docs/framework-comparison.md b/docs/framework-comparison.md
index cf8a3483..0969b2c9 100644
--- a/docs/framework-comparison.md
+++ b/docs/framework-comparison.md
@@ -74,7 +74,7 @@ What these numbers show is that not only does Mithril initializes significantly
Update performance can be even more important than first-render performance, since updates can happen many times while a Single Page Application is running.
-A useful tool to benchmark update performance is a tool developed by the Ember team called DbMonster. It updates a table as fast as it can and measures frames per second (FPS) and Javascript times (min, max and mean). The FPS count can be difficult to evaluate since it also includes browser repaint times and `setTimeout` clamping delay, so the most meaningful number to look at is the mean render time. You can compare a [React implementation](http://cdn.rawgit.com/lhorie/mithril.js/rewrite/examples/dbmonster/react/index.html) and a [Mithril implementation](http://cdn.rawgit.com/lhorie/mithril.js/rewrite/examples/dbmonster/mithril/index.html). Sample results are shown below:
+A useful tool to benchmark update performance is a tool developed by the Ember team called DbMonster. It updates a table as fast as it can and measures frames per second (FPS) and Javascript times (min, max and mean). The FPS count can be difficult to evaluate since it also includes browser repaint times and `setTimeout` clamping delay, so the most meaningful number to look at is the mean render time. You can compare a [React implementation](http://cdn.rawgit.com/MithrilJS/mithril.js/master/examples/dbmonster/react/index.html) and a [Mithril implementation](http://cdn.rawgit.com/MithrilJS/mithril.js/master/examples/dbmonster/mithril/index.html). Sample results are shown below:
React | Mithril
------- | -------
@@ -139,7 +139,7 @@ Also, remember that frameworks like Angular and Mithril are designed for non-tri
##### Update performance
-A useful tool to benchmark update performance is a tool developed by the Ember team called DbMonster. It updates a table as fast as it can and measures frames per second (FPS) and Javascript times (min, max and mean). The FPS count can be difficult to evaluate since it also includes browser repaint times and `setTimeout` clamping delay, so the most meaningful number to look at is the mean render time. You can compare an [Angular implementation](http://cdn.rawgit.com/lhorie/mithril.js/rewrite/examples/dbmonster/angular/index.html) and a [Mithril implementation](http://cdn.rawgit.com/lhorie/mithril.js/rewrite/examples/dbmonster/mithril/index.html). Both implementations are naive (i.e. no optimizations). Sample results are shown below:
+A useful tool to benchmark update performance is a tool developed by the Ember team called DbMonster. It updates a table as fast as it can and measures frames per second (FPS) and Javascript times (min, max and mean). The FPS count can be difficult to evaluate since it also includes browser repaint times and `setTimeout` clamping delay, so the most meaningful number to look at is the mean render time. You can compare an [Angular implementation](http://cdn.rawgit.com/MithrilJS/mithril.js/master/examples/dbmonster/angular/index.html) and a [Mithril implementation](http://cdn.rawgit.com/MithrilJS/mithril.js/master/examples/dbmonster/mithril/index.html). Both implementations are naive (i.e. no optimizations). Sample results are shown below:
Angular | Mithril
------- | -------
@@ -193,7 +193,7 @@ Library load times matter in applications that don't stay open for long periods
##### Update performance
-A useful tool to benchmark update performance is a tool developed by the Ember team called DbMonster. It updates a table as fast as it can and measures frames per second (FPS) and Javascript times (min, max and mean). The FPS count can be difficult to evaluate since it also includes browser repaint times and `setTimeout` clamping delay, so the most meaningful number to look at is the mean render time. You can compare a [Vue implementation](http://cdn.rawgit.com/lhorie/mithril.js/rewrite/examples/dbmonster/vue/index.html) and a [Mithril implementation](http://cdn.rawgit.com/lhorie/mithril.js/rewrite/examples/dbmonster/mithril/index.html). Both implementations are naive (i.e. no optimizations). Sample results are shown below:
+A useful tool to benchmark update performance is a tool developed by the Ember team called DbMonster. It updates a table as fast as it can and measures frames per second (FPS) and Javascript times (min, max and mean). The FPS count can be difficult to evaluate since it also includes browser repaint times and `setTimeout` clamping delay, so the most meaningful number to look at is the mean render time. You can compare a [Vue implementation](http://cdn.rawgit.com/MithrilJS/mithril.js/master/examples/dbmonster/vue/index.html) and a [Mithril implementation](http://cdn.rawgit.com/MithrilJS/mithril.js/master/examples/dbmonster/mithril/index.html). Both implementations are naive (i.e. no optimizations). Sample results are shown below:
Vue | Mithril
------ | -------
diff --git a/docs/generate.js b/docs/generate.js
index 52bc3e70..5650ae9d 100644
--- a/docs/generate.js
+++ b/docs/generate.js
@@ -12,9 +12,6 @@ try {fs.mkdirSync("./dist/archive/v" + version)} catch (e) {/* ignore */}
var guides = fs.readFileSync("docs/nav-guides.md", "utf-8")
var methods = fs.readFileSync("docs/nav-methods.md", "utf-8")
-var index = fs.readFileSync("docs/index.md", "utf-8")
-fs.writeFileSync("README.md", index.replace(/(\]\()(.+?)\.md(\))/g, "$1http://mithril.js.org/$2.html$3"), "utf-8")
-
generate("docs")
function generate(pathname) {
@@ -27,6 +24,7 @@ function generate(pathname) {
if (pathname.match(/\.md$/)) {
var outputFilename = pathname.replace(/\.md$/, ".html")
var markdown = fs.readFileSync(pathname, "utf-8")
+ var anchors = {}
var fixed = markdown
.replace(/`((?:\S| -> |, )+)(\|)(\S+)`/gim, function(match, a, b, c) { // fix pipes in code tags
return "" + (a + b + c).replace(/\|/g, "|") + ""
@@ -48,19 +46,26 @@ function generate(pathname) {
var title = fixed.match(/^#([^\n\r]+)/i) || []
var html = layout
.replace(/See the Pen Mithril Scaffold by Pat Cavit (@tivac) on CodePen.
+ + +Mithril is also loaded onto this page already, so you can start poking at the `m` object in the developer console right away if you'd like! + --- ### Hello world @@ -85,6 +92,11 @@ m.render(root, "My first app") As you can see, you use the same code to both create and update HTML. Mithril automatically figures out the most efficient way of updating the text, rather than blindly recreating it from scratch. +#### Live Example + +See the Pen Mithril Hello World by Pat Cavit (@tivac) on CodePen.
+ + --- ### DOM elements @@ -119,6 +131,11 @@ m("main", [ ]) ``` +#### Live Example + +See the Pen Simple Mithril Example by Pat Cavit (@tivac) on CodePen.
+ + Note: If you prefer `` syntax, [it's possible to use it via a Babel plugin](jsx.md). ```jsx @@ -185,6 +202,11 @@ You can now update the label of the button by clicking the button. Since we used If you're wondering about performance, it turns out Mithril is very fast at rendering updates, because it only touches the parts of the DOM it absolutely needs to. So in our example above, when you click the button, the text in it is the only part of the DOM Mithril actually updates. +#### Live Example + +See the Pen Mithril Component Example by Pat Cavit (@tivac) on CodePen.
+ + --- ### Routing @@ -218,6 +240,11 @@ The `"/splash"` right after `root` means that's the default route, i.e. if the h Also, as you would expect, clicking on the link on the splash page takes you to the click counter screen we created earlier. Notice that now your URL will point to `http://localhost/#!/hello`. You can navigate back and forth to the splash page using the browser's back and next button. +#### Live Example + +See the Pen Mithril Routing Example by Pat Cavit (@tivac) on CodePen.
+ + --- ### XHR @@ -260,6 +287,11 @@ var Hello = { Clicking the button should now update the count. +#### Live Example + +See the Pen Mithril XHR Example by Pat Cavit (@tivac) on CodePen.
+ + --- We covered how to create and update HTML, how to create components, routes for a Single Page Application, and interacted with a server via XHR. diff --git a/docs/installation.md b/docs/installation.md index f0c527bc..c4604ad5 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -219,7 +219,7 @@ If you don't have the ability to run a bundler script due to company security po