Skip to content
This repository was archived by the owner on Oct 24, 2021. It is now read-only.

Commit 0abf5f3

Browse files
committed
Change methodology for rendering sidebar sub-links.
Previously, the API box template was wrapping the "instance separator" (that is to say the hash symbol in something like `String#toString` with the HTML '<em>' tag in order to provide an italicised representation of that symbol. That styling seems to have been long lost and it's not clear how much value it added anyway (I tried, and didn't even notice). The value of this '<em>' wrapped "title" was being stored in the "title" attribute (commonly used for a mouseover tooltip) of the H2 tag for each section of the docs, though it was being improperly escaped so the actual HTML was showing in the tooltip. It's important to note that this "title" attribute is used to add "sub-links" to the sidebar at runtime. For an unspecified reason, meteor/meteor-theme-hexo@78ef415 added the escaping of this attribute when being used in the runtime generation of links. From the Meteor perspective, the content which was now being escaped did not need to be escaped (it already was), and therefore resulted HTMLesque titles being rendered into the sidebar. As it's not clear what the reason for this commit was (I'm assuming escaping is necessary for _some_ data coming into the sidebar, else the commit wouldn't have been necessary), and given that I have a fairly clear understanding of how the docs are instantiating this value, I'm opting to remove the escaping of the title attribute (which actually _didn't_ need to be escaped at all), but keep the escaping in place for the sub-link generation in the event that it's necessary elsewhere. It's situations like this where a verbose commit message can come in quite handy.
1 parent ac8e581 commit 0abf5f3

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

assets/api-box.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
{{locus}}
55
</div>
66

7-
<{{hTag}} title="{{title}}" class="title-api selflink" id={{id}}>
7+
<{{hTag}} title="{{{title}}}" class="title-api selflink" id={{id}}>
88
<a href="#{{id}}" class="link primary">{{{signature}}}</a>
99
</{{hTag}}>
1010

scripts/api-box.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -134,18 +134,18 @@ signature = function (data, options) {
134134
// TBH I'm not sure what else we use instanceName for (why we are setting for
135135
// e.g. `reactiveVar` if we don't want to show it here) but we opt into showing it
136136
if (memberOfData.showinstancename) {
137-
escapedLongname = "<em>" + memberOfData.instancename + "</em>." + data.name;
137+
escapedLongname = memberOfData.instancename + "." + data.name;
138138
} else if (options.short) {
139139
// Something#foo => #foo
140-
return '<em>' + options.instanceDelimiter + '</em>' + escapedLongname.split('#')[1];
140+
return options.instanceDelimiter + escapedLongname.split('#')[1];
141141
}
142142
}
143143

144144
// If the user passes in a instanceDelimiter and we are a static method,
145145
// we are probably underneath a heading that defines the object (e.g. DDPRateLimiter)
146146
if (data.scope === "static" && options.instanceDelimiter && options.short) {
147147
// Something.foo => .foo
148-
return '<em>' + options.instanceDelimiter + '</em>' + escapedLongname.split('.')[1];
148+
return options.instanceDelimiter + escapedLongname.split('.')[1];
149149
}
150150

151151
return escapedLongname + paramsStr;

0 commit comments

Comments
 (0)