mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-08-30 05:36:43 +02:00
Match any function name in error
This commit is contained in:
@@ -271,13 +271,15 @@ if (typeof document !== 'undefined') {
|
|||||||
*/
|
*/
|
||||||
window.addEventListener('load', contentLoaded, false);
|
window.addEventListener('load', contentLoaded, false);
|
||||||
window.addEventListener('error', ({ message }) => {
|
window.addEventListener('error', ({ message }) => {
|
||||||
if (message.includes('mermaid.initialize is not a function')) {
|
// Get mermaid function called from error message with regex
|
||||||
|
const match = message.match(/mermaid\.(\w+) is not a function/);
|
||||||
|
if (match) {
|
||||||
const notify = () =>
|
const notify = () =>
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
console.error(`------------------------------
|
console.error(`------------------------------
|
||||||
Breaking change in Mermaid v11
|
Breaking change in Mermaid v11
|
||||||
------------------------------
|
------------------------------
|
||||||
Use mermaid.default.initialize() instead of mermaid.initialize()
|
Use mermaid.default.${match[1]}() instead of mermaid.${match[1]}()
|
||||||
Read more: https://github.com/mermaid-js/mermaid/releases/tag/v11.0.0
|
Read more: https://github.com/mermaid-js/mermaid/releases/tag/v11.0.0
|
||||||
`);
|
`);
|
||||||
notify();
|
notify();
|
||||||
|
Reference in New Issue
Block a user