Skip to content

Commit 80c54ba

Browse files
authored
#5305 Fix ReferenceError: toTitleCase undefined in planet UI (#5305)
* Fix ReferenceError: toTitleCase undefined in planet UI * Fix toTitleCase availability for browser and tests * Use shared toTitleCase from js/utils/utils.js in planet UI * Making it work in both environment * } wasnt ther * Changes done
1 parent 92fa530 commit 80c54ba

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

js/utils/utils.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -562,13 +562,20 @@ let fileBasename = file => {
562562
* @param {string} str - The input string.
563563
* @returns {string} The string with the first character in uppercase.
564564
*/
565-
let toTitleCase = str => {
565+
function toTitleCase (str) {
566566
if (typeof str !== "string") return;
567567
let tempStr = "";
568568
if (str.length > 1) tempStr = str.substring(1);
569569
return str.toUpperCase()[0] + tempStr;
570570
};
571571

572+
if (typeof module !== "undefined" && module.exports) {
573+
module.exports.toTitleCase = toTitleCase;
574+
}
575+
if (typeof window !== "undefined") {
576+
window.toTitleCase = toTitleCase;
577+
}
578+
572579
/**
573580
* Processes plugin data and updates the activity based on the provided JSON-encoded dictionary.
574581
* @param {object} activity - The activity object to update.

planet/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
<script type="text/javascript" src="js/Publisher.js"></script>
3636
<script type="text/javascript" src="js/LocalPlanet.js"></script>
3737

38+
<script type="text/javascript" src="js/utils.js"></script>
3839
<script type="text/javascript" src="js/GlobalTag.js"></script>
3940
<script type="text/javascript" src="js/GlobalCard.js"></script>
4041
<script type="text/javascript" src="js/ProjectViewer.js"></script>

planet/js/utils.js

Whitespace-only changes.

0 commit comments

Comments
 (0)