From c2f269c3b48f02251fbb5c188bb542f2183eea0b Mon Sep 17 00:00:00 2001 From: Isiah Meadows Date: Tue, 16 Jul 2019 07:16:25 -0400 Subject: [PATCH] Fix design bug (#2475) --- api/router.js | 4 ++-- api/tests/test-router.js | 4 ++-- docs/route.md | 22 +++++++++++----------- docs/signatures.md | 20 ++++++++++---------- 4 files changed, 25 insertions(+), 25 deletions(-) diff --git a/api/router.js b/api/router.js index d224b4a6..f52d83f4 100644 --- a/api/router.js +++ b/api/router.js @@ -191,14 +191,14 @@ module.exports = function($window, mountRedraw) { assign(attrs, vnode.attrs) // The first two are internal, but the rest are magic attributes // that need censored to not screw up rendering. - attrs.component = attrs.options = attrs.key = attrs.oninit = + attrs.selector = attrs.options = attrs.key = attrs.oninit = attrs.oncreate = attrs.onbeforeupdate = attrs.onupdate = attrs.onbeforeremove = attrs.onremove = null // Do this now so we can get the most current `href` and `disabled`. // Those attributes may also be specified in the selector, and we // should honor that. - var child = m(vnode.attrs.component || "a", attrs, vnode.children) + var child = m(vnode.attrs.selector || "a", attrs, vnode.children) // Let's provide a *right* way to disable a route link, rather than // letting people screw up accessibility on accident. diff --git a/api/tests/test-router.js b/api/tests/test-router.js index cec9c411..56f617ce 100644 --- a/api/tests/test-router.js +++ b/api/tests/test-router.js @@ -615,7 +615,7 @@ o.spec("route", function() { route.prefix = prefix root = $window.document.body - render(root, m(route.Link, {component: "button", href: "/test", foo: "bar"}, "text")) + render(root, m(route.Link, {selector: "button", href: "/test", foo: "bar"}, "text")) o(root.childNodes.length).equals(1) o(root.firstChild.nodeName).equals("BUTTON") @@ -635,7 +635,7 @@ o.spec("route", function() { route.prefix = prefix root = $window.document.body - render(root, m(route.Link, {component: "button[href=/test]", foo: "bar"}, "text")) + render(root, m(route.Link, {selector: "button[href=/test]", foo: "bar"}, "text")) o(root.childNodes.length).equals(1) o(root.firstChild.nodeName).equals("BUTTON") diff --git a/docs/route.md b/docs/route.md index de76b688..c825db95 100644 --- a/docs/route.md +++ b/docs/route.md @@ -144,7 +144,7 @@ You can pass other attributes, too, and you can also specify the tag name used. m(m.route.Link, { // Any hyperscript selector is valid here - it's literally passed as the // first parameter to `m`. - component: "span", + selector: "span", options: {replace: true}, href: "/test", disabled: false, @@ -154,7 +154,7 @@ m(m.route.Link, { }, "link name") ``` -Magic attributes used by this component (except `href` and `disabled`) *are* removed while proxying, so you won't have an odd `component="span"` or `options="[object Object]"` attribute show up in your link's DOM node. The above component renders to this hyperscript, assuming the prefix is the default `#!`: +Magic attributes used by this selector (except `href` and `disabled`) *are* removed while proxying, so you won't have an odd `selector="span"` or `options="[object Object]"` attribute show up in your link's DOM node. The above vnode renders to this hyperscript, assuming the prefix is the default `#!`: ```javascript m("span", { @@ -202,15 +202,15 @@ Do note that this doesn't also disable pointer events for you - you have to do t `vnode = m(m.route.Link, attributes, children)` -Argument | Type | Required | Description ----------------------- | ------------------------------------ | -------- | --- -`attributes.href` | `Object` | Yes | The target route to navigate to. -`attributes.component` | `String|Object|Function` | No | This sets the tag name to use. Must be a valid selector for [`m`](hyperscript.md) if given, defaults to `"a"`. -`attributes.options` | `Object` | No | This sets the options passed to [`m.route.set`](#mrouteset). -`attributes.disabled` | `Object` | No | This sets the options passed to [`m.route.set`](#mrouteset). -`attributes` | `Object` | No | Other attributes to apply to the returned vnode may be passed. -`children` | `Array|String|Number|Boolean` | No | Child [vnodes](vnodes.md) for this link. -**returns** | `Vnode` | | A [vnode](vnodes.md). +Argument | Type | Required | Description +--------------------- | ------------------------------------ | -------- | --- +`attributes.href` | `Object` | Yes | The target route to navigate to. +`attributes.selector` | `String|Object|Function` | No | This sets the tag name to use. Must be a valid selector for [`m`](hyperscript.md) if given, defaults to `"a"`. +`attributes.options` | `Object` | No | This sets the options passed to [`m.route.set`](#mrouteset). +`attributes.disabled` | `Object` | No | This sets the options passed to [`m.route.set`](#mrouteset). +`attributes` | `Object` | No | Other attributes to apply to the returned vnode may be passed. +`children` | `Array|String|Number|Boolean` | No | Child [vnodes](vnodes.md) for this link. +**returns** | `Vnode` | | A [vnode](vnodes.md). ##### m.route.param diff --git a/docs/signatures.md b/docs/signatures.md index a2c306ad..801f3b05 100644 --- a/docs/signatures.md +++ b/docs/signatures.md @@ -57,22 +57,22 @@ Functions with multiple arguments are denoted with parenthesis: `(String, Array) ### Component signatures -Components are denoted via calls to `m`, but with the selector argument set to a constant named in the relevant prose: +Components are denoted via calls to `m`, but with the initial selector argument set to a constant named in the relevant prose: `vnode = m(m.route.Link, attributes, children)` -Argument | Type | Required | Description ----------------------- | ------------------------------------ | -------- | --- -`attributes.href` | `Object` | Yes | The target route to navigate to. -`attributes.component` | `String|Object|Function` | No | This sets the tag name to use. Must be a valid selector for [`m`](hyperscript.md) if given, defaults to `"a"`. -`attributes.options` | `Object` | No | This sets the options passed to [`m.route.set`](#mrouteset). -`attributes` | `Object` | No | Other attributes to apply to the returned vnode may be passed. -`children` | `Array|String|Number|Boolean` | No | Child [vnodes](vnodes.md) for this link. -**returns** | `Vnode` | | A [vnode](vnodes.md). +Argument | Type | Required | Description +--------------------- | ------------------------------------ | -------- | --- +`attributes.href` | `Object` | Yes | The target route to navigate to. +`attributes.selector` | `String|Object|Function` | No | This sets the tag name to use. Must be a valid selector for [`m`](hyperscript.md) if given, defaults to `"a"`. +`attributes.options` | `Object` | No | This sets the options passed to [`m.route.set`](#mrouteset). +`attributes` | `Object` | No | Other attributes to apply to the returned vnode may be passed. +`children` | `Array|String|Number|Boolean` | No | Child [vnodes](vnodes.md) for this link. +**returns** | `Vnode` | | A [vnode](vnodes.md). Children here, if specified, are assumed to be able to be written as [splat arguments](#splats), unless otherwise specified in prose. -An element with no sensible children and/or attributes may elect to elide the relevant parameter entirely, so it might look closer to this: +An element with no sensible children and/or attributes may choose to elide the relevant parameter entirely: `vnode = m(Component, attributes)`