From b9c3c6c9c803367a036362b9b058547d68bb76d9 Mon Sep 17 00:00:00 2001 From: Isiah Meadows Date: Sun, 28 Oct 2018 17:00:47 -0400 Subject: [PATCH] Remove a section that's 1. buggy and 2. controversial [skip ci] (#2265) See discussion in #2250 and #1986 for more details. --- docs/change-log.md | 2 +- docs/components.md | 30 ------------------------------ 2 files changed, 1 insertion(+), 31 deletions(-) diff --git a/docs/change-log.md b/docs/change-log.md index 239dbed7..5ec5f0f3 100644 --- a/docs/change-log.md +++ b/docs/change-log.md @@ -58,7 +58,7 @@ - render/events: `Object.prototype` properties can no longer interfere with event listener calls. - render/events: Event handlers, when set to literally `undefined` (or any non-function), are now correctly removed. - render/hooks: fixed an ommission that caused `oninit` to be called unnecessarily in some cases [#1992](https://github.com/MithrilJS/mithril.js/issues/1992) -- docs: tweaks: ([#2104](https://github.com/MithrilJS/mithril.js/pull/2104) [@mikeyb](https://github.com/mikeyb), [#2205](https://github.com/MithrilJS/mithril.js/pull/2205), [@cavemansspa](https://github.com/cavemansspa)) +- docs: tweaks: ([#2104](https://github.com/MithrilJS/mithril.js/pull/2104) [@mikeyb](https://github.com/mikeyb), [#2205](https://github.com/MithrilJS/mithril.js/pull/2205), [@cavemansspa](https://github.com/cavemansspa), [#2265](https://github.com/MithrilJS/mithril.js/pull/2265), [@isiahmeadows](https://github.com/isiahmeadows)) - render/core: avoid touching `Object.prototype.__proto__` setter with `key: "__proto__"` in certain situations ([#2251](https://github.com/MithrilJS/mithril.js/pull/2251)) --- diff --git a/docs/components.md b/docs/components.md index cbb97cc0..89ccf2b0 100644 --- a/docs/components.md +++ b/docs/components.md @@ -363,36 +363,6 @@ This way, the `Auth` module is now the source of truth for auth-related state, a As a bonus, notice that we no longer need to use `.bind` to keep a reference to the state for the component's event handlers. -#### Avoid restrictive interfaces - -Try to keep component interfaces generic - using `attrs` and `children` directly - unless the component requires special logic to operate on input. - -In the example below, the `button` configuration is severely limited: it does not support any events other than `onclick`, it's not styleable and it only accepts text as children (but not elements, fragments or trusted HTML). - -```javascript -// AVOID -var RestrictiveComponent = { - view: function(vnode) { - return m("button", {onclick: vnode.attrs.onclick}, [ - "Click to " + vnode.attrs.text - ]) - } -} -``` - -If the required attributes are equivalent to generic DOM attributes, it's preferable to allow passing through parameters to a component's root node. - -```javascript -// PREFER -var FlexibleComponent = { - view: function(vnode) { - return m("button", vnode.attrs, [ - "Click to ", vnode.children - ]) - } -} -``` - #### Don't manipulate `children` If a component is opinionated in how it applies attributes or children, you should switch to using custom attributes.