Empty or missing type on genesis widget should not render an element/widget

Fixes #7153
This commit is contained in:
jeremy@jermolene.com 2022-12-30 21:42:07 +00:00
parent bf8e1ca5b0
commit 42a408146d
3 changed files with 23 additions and 2 deletions

View File

@ -42,10 +42,15 @@ Compute the internal state of the widget
GenesisWidget.prototype.execute = function() {
var self = this;
// Collect attributes
this.genesisType = this.getAttribute("$type","element");
this.genesisType = this.getAttribute("$type");
this.genesisRemappable = this.getAttribute("$remappable","yes") === "yes";
this.genesisNames = this.getAttribute("$names","");
this.genesisValues = this.getAttribute("$values","");
// Do not create a child widget if the $type attribute is missing or blank
if(!this.genesisType) {
this.makeChildWidgets(this.parseTreeNode.children);
return;
}
// Construct parse tree
var isElementWidget = this.genesisType.charAt(0) !== "$",
nodeType = isElementWidget ? "element" : this.genesisType.substr(1),

View File

@ -0,0 +1,14 @@
title: Genesis/EmptyType
description: Using an empty type attribute with the genesis widget
type: text/vnd.tiddlywiki-multiple
tags: [[$:/tags/wiki-test-spec]]
title: Output
<$genesis>Mouse</$genesis>
<$genesis $type="">Mouse</$genesis>
+
title: ExpectedResult
<p>Mouse</p><p>Mouse</p>

View File

@ -1,6 +1,6 @@
caption: genesis
created: 20221101100729587
modified: 20221101100729587
modified: 20221230213912929
tags: Widgets
title: GenesisWidget
type: text/vnd.tiddlywiki
@ -21,6 +21,8 @@ The content of the <<.wlink GenesisWidget>> widget is used as the content of the
|//{attributes starting with $$}// |Attributes starting with two dollar signs are appplied as attributes to the output widget, but with the attribute name changed to use a single dollar sign |
|//{attributes not starting with $}// |Any other attributes that do not start with a dollar are applied as attributes to the output widget |
<<.from-version "5.2.6">> If the `$type` attribute is missing or blank, the <<.wlink GenesisWidget>> widget does not render an intrinsic element, instead just rendering its children.
Note that attributes explicitly specified take precedence over attributes with the same name specified in the `$names` filter.
! Examples