1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2026-05-22 13:22:23 +00:00

Compare commits

..

1 Commits

Author SHA1 Message Date
Jeremy Ruston 7fe17993dc Intentionally throw an error when running tests in the browser 2023-10-30 10:06:27 +00:00
5 changed files with 8 additions and 92 deletions
+3 -3
View File
@@ -2,6 +2,9 @@
# test TiddlyWiki5 for tiddlywiki.com # test TiddlyWiki5 for tiddlywiki.com
npm install playwright @playwright/test
npx playwright install chromium firefox --with-deps
node ./tiddlywiki.js \ node ./tiddlywiki.js \
./editions/test \ ./editions/test \
--verbose \ --verbose \
@@ -10,7 +13,4 @@ node ./tiddlywiki.js \
--test \ --test \
|| exit 1 || exit 1
npm install playwright @playwright/test
npx playwright install chromium firefox --with-deps
npx playwright test npx playwright test
-46
View File
@@ -1,46 +0,0 @@
/*\
title: $:/core/modules/commands/jsrepl.js
type: application/javascript
module-type: command
Command to launch node.js REPL with access to $tw
\*/
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
exports.info = {
name: "jsrepl",
synchronous: true
};
var Command = function(params,commander,callback) {
var self = this;
this.params = params;
this.commander = commander;
this.callback = callback;
};
Command.prototype.execute = function() {
var self = this;
var repl = require("repl");
this.runtime = repl.start({
prompt: this.params.length ? this.params[0] : "$tw-jsrepl> ",
useColors: true,
ignoreUndefined: true
});
// If REPL is reset (.clear) - context needs resetting
this.runtime.on("reset", function() {
self.runtime.context.$tw = $tw;
});
// Initial context settings
this.runtime.context.$tw = $tw;
return null;
};
exports.Command = Command;
})();
+1 -1
View File
@@ -52,7 +52,7 @@ exports.tag = function(source,operator,options) {
} }
} }
} }
return results; return $tw.browser ? results.reverse() : results;
}; };
})(); })();
@@ -194,7 +194,6 @@ Parse any pragmas at the beginning of a block of parse text
WikiParser.prototype.parsePragmas = function() { WikiParser.prototype.parsePragmas = function() {
var currentTreeBranch = this.tree; var currentTreeBranch = this.tree;
while(true) { while(true) {
var savedPos = this.pos;
// Skip whitespace // Skip whitespace
this.skipWhitespace(); this.skipWhitespace();
// Check for the end of the text // Check for the end of the text
@@ -205,7 +204,6 @@ WikiParser.prototype.parsePragmas = function() {
var nextMatch = this.findNextMatch(this.pragmaRules,this.pos); var nextMatch = this.findNextMatch(this.pragmaRules,this.pos);
// If not, just exit // If not, just exit
if(!nextMatch || nextMatch.matchIndex !== this.pos) { if(!nextMatch || nextMatch.matchIndex !== this.pos) {
this.pos = savedPos;
break; break;
} }
// Process the pragma rule // Process the pragma rule
+4 -40
View File
@@ -28,18 +28,6 @@ Inherit from the base widget class
*/ */
ListWidget.prototype = new Widget(); ListWidget.prototype = new Widget();
ListWidget.prototype.initialise = function(parseTreeNode,options) {
// Bail if parseTreeNode is undefined, meaning that the ListWidget constructor was called without any arguments so that it can be subclassed
if(parseTreeNode === undefined) {
return;
}
// First call parent constructor to set everything else up
Widget.prototype.initialise.call(this,parseTreeNode,options);
// Now look for <$list-template> and <$list-empty> widgets as immediate child widgets
// This is safe to do during initialization because parse trees never change after creation
this.findExplicitTemplates();
}
/* /*
Render this widget into the DOM Render this widget into the DOM
*/ */
@@ -80,6 +68,8 @@ ListWidget.prototype.execute = function() {
this.counterName = this.getAttribute("counter"); this.counterName = this.getAttribute("counter");
this.storyViewName = this.getAttribute("storyview"); this.storyViewName = this.getAttribute("storyview");
this.historyTitle = this.getAttribute("history"); this.historyTitle = this.getAttribute("history");
// Look for <$list-template> and <$list-empty> widgets as immediate child widgets
this.findExplicitTemplates();
// Compose the list elements // Compose the list elements
this.list = this.getTiddlerList(); this.list = this.getTiddlerList();
var members = [], var members = [],
@@ -102,7 +92,6 @@ ListWidget.prototype.findExplicitTemplates = function() {
var self = this; var self = this;
this.explicitListTemplate = null; this.explicitListTemplate = null;
this.explicitEmptyTemplate = null; this.explicitEmptyTemplate = null;
this.hasTemplateInBody = false;
var searchChildren = function(childNodes) { var searchChildren = function(childNodes) {
$tw.utils.each(childNodes,function(node) { $tw.utils.each(childNodes,function(node) {
if(node.type === "list-template") { if(node.type === "list-template") {
@@ -111,8 +100,6 @@ ListWidget.prototype.findExplicitTemplates = function() {
self.explicitEmptyTemplate = node.children; self.explicitEmptyTemplate = node.children;
} else if(node.type === "element" && node.tag === "p") { } else if(node.type === "element" && node.tag === "p") {
searchChildren(node.children); searchChildren(node.children);
} else {
self.hasTemplateInBody = true;
} }
}); });
}; };
@@ -173,11 +160,11 @@ ListWidget.prototype.makeItemTemplate = function(title,index) {
// Check for a <$list-item> widget // Check for a <$list-item> widget
if(this.explicitListTemplate) { if(this.explicitListTemplate) {
templateTree = this.explicitListTemplate; templateTree = this.explicitListTemplate;
} else if(this.hasTemplateInBody) { } else if (!this.explicitEmptyTemplate) {
templateTree = this.parseTreeNode.children; templateTree = this.parseTreeNode.children;
} }
} }
if(!templateTree || templateTree.length === 0) { if(!templateTree) {
// Default template is a link to the title // Default template is a link to the title
templateTree = [{type: "element", tag: this.parseTreeNode.isBlock ? "div" : "span", children: [{type: "link", attributes: {to: {type: "string", value: title}}, children: [ templateTree = [{type: "element", tag: this.parseTreeNode.isBlock ? "div" : "span", children: [{type: "link", attributes: {to: {type: "string", value: title}}, children: [
{type: "text", text: title} {type: "text", text: title}
@@ -427,27 +414,4 @@ ListItemWidget.prototype.refresh = function(changedTiddlers) {
exports.listitem = ListItemWidget; exports.listitem = ListItemWidget;
/*
Make <$list-template> and <$list-empty> widgets that do nothing
*/
var ListTemplateWidget = function(parseTreeNode,options) {
// Main initialisation inherited from widget.js
this.initialise(parseTreeNode,options);
};
ListTemplateWidget.prototype = new Widget();
ListTemplateWidget.prototype.render = function() {}
ListTemplateWidget.prototype.refresh = function() { return false; }
exports["list-template"] = ListTemplateWidget;
var ListEmptyWidget = function(parseTreeNode,options) {
// Main initialisation inherited from widget.js
this.initialise(parseTreeNode,options);
};
ListEmptyWidget.prototype = new Widget();
ListEmptyWidget.prototype.render = function() {}
ListEmptyWidget.prototype.refresh = function() { return false; }
exports["list-empty"] = ListEmptyWidget;
})(); })();