mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-01-22 15:06:52 +00:00
fix: when currentTiddler not set, don't set title on id
This commit is contained in:
parent
f4d7095a33
commit
8fcd08d7ca
@ -3,7 +3,7 @@ title: $:/core/modules/widgets/block-mark.js
|
||||
type: application/javascript
|
||||
module-type: widget
|
||||
|
||||
An invisible element with block mark id metadata. Marking a block level element, so that it can be jumped to.
|
||||
An invisible element with block mark id metadata. Marking a block level element, so that it can be jumped to or transcluded.
|
||||
\*/
|
||||
var Widget = require("$:/core/modules/widgets/widget.js").widget;
|
||||
var BlockMarkWidget = function(parseTreeNode,options) {
|
||||
@ -21,9 +21,13 @@ BlockMarkWidget.prototype.render = function(parent,nextSibling) {
|
||||
// Create an invisible DOM element with data that can be accessed from JS or CSS
|
||||
this.idNode = this.document.createElement("span");
|
||||
this.idNode.setAttribute("data-block-mark-id",this.blockMarkId);
|
||||
this.idNode.setAttribute("data-block-mark-title",this.tiddlerTitle);
|
||||
// id for anchor jumping in static site
|
||||
this.idNode.setAttribute("id",this.tiddlerTitle + "-" + this.blockMarkId);
|
||||
if(this.tiddlerTitle) {
|
||||
this.idNode.setAttribute("data-block-mark-title",this.tiddlerTitle);
|
||||
// id for anchor jumping in static site
|
||||
this.idNode.setAttribute("id",this.tiddlerTitle + "-" + this.blockMarkId);
|
||||
} else {
|
||||
this.idNode.setAttribute("id",this.blockMarkId);
|
||||
}
|
||||
// if the actual block is before this node, we need to add a flag to the node
|
||||
if(this.previousSibling) {
|
||||
this.idNode.setAttribute("data-block-mark-previous-sibling","true");
|
||||
@ -39,7 +43,7 @@ Compute the internal state of the widget
|
||||
BlockMarkWidget.prototype.execute = function() {
|
||||
// Get the id from the parse tree node or manually assigned attributes
|
||||
this.blockMarkId = this.getAttribute("id");
|
||||
this.tiddlerTitle = this.getVariable("currentTiddler");
|
||||
this.tiddlerTitle = this.getVariable("currentTiddler", "");
|
||||
this.previousSibling = this.getAttribute("previousSibling") === "yes";
|
||||
// Make the child widgets
|
||||
this.makeChildWidgets();
|
||||
|
Loading…
Reference in New Issue
Block a user