diff --git a/V10-BreakingChanges.md b/V10-BreakingChanges.md new file mode 100644 index 000000000..bd9110d1a --- /dev/null +++ b/V10-BreakingChanges.md @@ -0,0 +1,5 @@ +# A collection of updates that change the behaviour + +## Lazy loading and asynchronisity + +- Invalid dates are rendered as syntax error instead of returning best guess or the current date diff --git a/cypress/integration/rendering/gantt.spec.js b/cypress/integration/rendering/gantt.spec.js index 438b80267..16a70ece0 100644 --- a/cypress/integration/rendering/gantt.spec.js +++ b/cypress/integration/rendering/gantt.spec.js @@ -92,7 +92,7 @@ describe('Gantt diagram', () => { {} ); }); - it('should render a gantt chart for issue #1060', () => { + it('should FAIL redering a gantt chart for issue #1060 with invalid date', () => { imgSnapshotTest( ` gantt diff --git a/cypress/platform/knsv2.html b/cypress/platform/knsv2.html index 313dd72ba..506ac51ae 100644 --- a/cypress/platform/knsv2.html +++ b/cypress/platform/knsv2.html @@ -56,7 +56,7 @@
Security check
-      classDiagram
+classDiagram
         direction LR
         class Student {
           -idCard : IdCard
diff --git a/package.json b/package.json
index c1c33920f..431f89bad 100644
--- a/package.json
+++ b/package.json
@@ -126,7 +126,6 @@
     "jsdom": "^20.0.1",
     "lint-staged": "^13.0.3",
     "markdown-it": "^13.0.1",
-    "moment": "^2.23.0",
     "path-browserify": "^1.0.1",
     "pnpm": "^7.13.2",
     "prettier": "^2.7.1",
diff --git a/packages/mermaid/src/diagrams/class/svgDraw.js b/packages/mermaid/src/diagrams/class/svgDraw.js
index 8212eb4bd..9a4dc761e 100644
--- a/packages/mermaid/src/diagrams/class/svgDraw.js
+++ b/packages/mermaid/src/diagrams/class/svgDraw.js
@@ -372,11 +372,11 @@ const buildLegacyDisplay = function (text) {
 
     const parameters = text.substring(methodStart + 1, methodEnd);
     const classifier = text.substring(methodEnd + 1, 1);
-    cssStyle = parseClassifier(classifier);
+    cssStyle = parseClassifier(text.substring(methodEnd + 1, methodEnd + 2));
 
     displayText = visibility + methodName + '(' + parseGenericTypes(parameters.trim()) + ')';
 
-    if (methodEnd < memberText.length) {
+    if (methodEnd < text.length) {
       returnType = text.substring(methodEnd + 2).trim();
       if (returnType !== '') {
         returnType = ' : ' + parseGenericTypes(returnType);
diff --git a/packages/mermaid/src/diagrams/gantt/ganttDb.js b/packages/mermaid/src/diagrams/gantt/ganttDb.js
index 5d072b903..9183cc766 100644
--- a/packages/mermaid/src/diagrams/gantt/ganttDb.js
+++ b/packages/mermaid/src/diagrams/gantt/ganttDb.js
@@ -217,10 +217,12 @@ const getStartDate = function (prevTime, dateFormat, str) {
   } else {
     log.debug('Invalid date:' + str);
     log.debug('With date format:' + dateFormat.trim());
+    const d = new Date(str);
+    if (typeof d === 'undefined' || isNaN(d.getTime())) {
+      throw new Error('Invalid date:' + str);
+    }
+    return d;
   }
-
-  // Default date - now
-  return new Date();
 };
 
 /**
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 9cb8306ea..89b929342 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -56,7 +56,6 @@ importers:
       lint-staged: ^13.0.3
       lodash: ^4.17.21
       markdown-it: ^13.0.1
-      moment: ^2.23.0
       moment-mini: ^2.24.0
       non-layered-tidy-tree-layout: ^2.0.2
       path-browserify: ^1.0.1
@@ -133,7 +132,6 @@ importers:
       jsdom: 20.0.1
       lint-staged: 13.0.3
       markdown-it: 13.0.1
-      moment: 2.29.4
       path-browserify: 1.0.1
       pnpm: 7.13.2
       prettier: 2.7.1