Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bad error message when function link function is undefined #74

Closed
NQNStudios opened this issue Jan 4, 2018 · 2 comments
Closed

Bad error message when function link function is undefined #74

NQNStudios opened this issue Jan 4, 2018 · 2 comments
Labels

Comments

@NQNStudios
Copy link
Collaborator

What happened

I had mis-typed the name of a function in a function link. When clicking the link to go to the section containing the function link, the section link would become disabled, and the console would error:
TypeError: Argument 2 of EventTarget.addEventListener is not an object.

As far as I can tell, the issue is that RegisterLinks() is failing to register the links in the new section, and never visiting the new section at all. So it seems like the error is actually coming from a different section than the one it is.

Steps to reproduce

{{Start}}

[Link1]({@Section2})

{{Section2}}

[Link2]({#notARealFunction})

Expected behavior

An error message should point out that the function doesn't exist, and print the name. Maybe it should even make the second section appear, but with the broken link highlighted red or something.

@invicticide
Copy link
Owner

If you still see RegisterLinks being called then you're behind the main repo, since that's been refactored to ActivateElement now. But with that being said, I suspect the issue is that in ActivateElement, we do this for a function link:

case "data-call-function":
{
	element.addEventListener("click", RetrieveFromWindow(element.attributes[i].value, 'function'));
	break;
}

Note that if RetrieveFromWindow hands back a null then we're going to try to bind a null function to the "click" event listener, which is probably the root cause of the error.

@invicticide invicticide added the bug label Jan 4, 2018
@NQNStudios
Copy link
Collaborator Author

You're right, it is ActivateElement. I just didn't look too closely at the source.

@NQNStudios NQNStudios closed this as not planned Won't fix, can't repro, duplicate, stale Sep 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants