Bug in $genesis widget precedence?

As a simple example of overriding a widget in the new //Grok TiddlyWiki//, I’m trying to override the $link widget to change the target. This works great until I try to use $params, $names, and $values to pass through all the possible parameters to $link that I don’t want to change. Here’s my example:

\widget $link()
<$parameters $params="params-var">
	<$genesis
			$type="$link"
			$remappable="no"
			$names="[<params-var>jsonindexes[]]"
			$values="[<params-var>jsonindexes[]] :map[<params-var>jsonget<currentTiddler>]"
			to="New Target"
			>
				<$slot $name="ts-raw">
	</$genesis>
</$parameters>
\end

* <$link to="Links" tooltip="xyz">Ttip Link</$link> to a tiddler
* [[Links]] are a fundamental part of a TiddlyWiki.

What happens is that the to parameter to $genesis I’ve explicitly specified is not honoured – the to parameter on my original $link widget is used instead, defeating the purpose of overriding the widget (in this example, both links link to Links instead of to New Target; if I delete the $names and $values parameters, the targets change as expected).

I would assume that overriding the version in $names and $values was something that was just not supported, except the widget documentation on tiddlywiki.com carefully notes that this is supported:

Note that attributes explicitly specified take precedence over attributes with the same name specified in the $names filter.

Am I missing something, or is this just behaving wrong?

Thanks @sobjornstad. Contrary to the documentation, the code actually processes the explicit attributes (like “to” in your example) before it processes the $names/$values attributes.

In these situations we would generally prefer to change the code to match the documentation, but we would have to do some analysis of the impact.

I hacked a quick change and found that one test fails, not surprisingly since it is testing this precise behaviour.

We should probably move that discussion to GitHub, but in the meantime you can workaround the issue by applying the “to” attribute within the $names/$values attributes::

\widget $link()
<$parameters $params="params-var">
	<$genesis
			$type="$link"
			$remappable="no"
			$names="[<params-var>jsonindexes[]] =to"
			$values="[<params-var>jsonindexes[]] :map[<params-var>jsonget<currentTiddler>] =[[New Target]]"
			>
				<$slot $name="ts-raw">
	</$genesis>
</$parameters>
\end

* <$link to="Links" tooltip="xyz">Ttip Link</$link> to a tiddler
* [[Links]] are a fundamental part of a TiddlyWiki.
3 Likes