Skip to content

Commit

Permalink
[docs] #2174 docs and change log
Browse files Browse the repository at this point in the history
  • Loading branch information
pygy committed Jun 7, 2018
1 parent 32b319d commit fed0846
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 2 additions & 0 deletions docs/change-log.md
Expand Up @@ -24,6 +24,8 @@
- 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))
- API: Assigning to `vnode.state` (as in `vnode.state = ...`) is no longer supported. Instead, an error is thrown if `vnode.state` changes upon the invocation of a lifecycle hook.
- API: `m.request` will no longer reject the Promise on server errors (eg. status >= 400) if the caller supplies an `extract` callback. This gives applications more control over handling server responses.
- hyperscript: when attributes have a `null` or `undefined` value, they are treated as if they were absent. [#1773](https://github.com/MithrilJS/mithril.js/issues/1773) ([#2174](https://github.com/MithrilJS/mithril.js/pull/2174))
- hyperscript: when an attribute is defined on both the first and second argument (as a CSS selector and an `attrs` field, respectively), the latter takes precedence, except for `class` attributes that are still added together. [#2172](https://github.com/MithrilJS/mithril.js/issues/2172) ([#2174](https://github.com/MithrilJS/mithril.js/pull/2174))

#### News

Expand Down
19 changes: 18 additions & 1 deletion docs/hyperscript.md
Expand Up @@ -5,6 +5,7 @@
- [How it works](#how-it-works)
- [Flexibility](#flexibility)
- [CSS selectors](#css-selectors)
- [Attributes passed as the second argument](attributes-passed-as-the-second-argument)
- [DOM attributes](#dom-attributes)
- [Style attribute](#style-attribute)
- [Events](#events)
Expand Down Expand Up @@ -144,7 +145,23 @@ m("a.link[href=/]", {
// <a href="/" class="link selected">Home</a>
```

If there are class names in both first and second arguments of `m()`, they are merged together as you would expect.
### Attributes passed as the second argument

You can pass attributes, properties, events and lifecycle hooks in the second, optional argument (see the next sections for details).

```JS
m("button", {
class: "my-button",
onclick: function() {/* ... */},
oncreate: function() {/* ... */}
})
```

If the value of such an attribute is `null` or `undefined`, it is treated as if the attribute was absent.

If there are class names in both first and second arguments of `m()`, they are merged together as you would expect. If the value of the class in the second argument is `null`or `undefined`, it is ignored.

If another attribute is present in both the first and the second argument, the second one takes precedence even if it is is `null` or `undefined`.

---

Expand Down

0 comments on commit fed0846

Please sign in to comment.