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

wiki: version selector doesn't work in function API pages #8

Open
slime73 opened this issue Jan 19, 2022 · 5 comments
Open

wiki: version selector doesn't work in function API pages #8

slime73 opened this issue Jan 19, 2022 · 5 comments

Comments

@slime73
Copy link
Member

slime73 commented Jan 19, 2022

For example on this page https://love2d.org/wiki/love.graphics.newMesh if you select Latest Version in the version selector it should hide the "Available since" tags, and hide the entire variant sections for the removed variants, but it doesn't right now.

I did a bit of debugging (despite not knowing JS or SMW very well) and I think I found at least one problem: this code finds the first h2 and wraps it as well as all its immediate siblings.
In old cached versions of the wiki from before recent upgrades, the h2's were all around the top level of the hierarchy. But now there's one that's a child of a "toctitle" class so I think it's finding that and then exiting the loop since it has no siblings.

Maybe it'll work to change that code to use document.querySelectorAll instead of iterating through document.querySelector's siblings?

@TheLinx
Copy link
Collaborator

TheLinx commented Jan 19, 2022

Even with a working wrapSections it doesn't seem to do hide the available since tags.

	function wrapSections () {
		var list = document.querySelectorAll('h2');
		var wrapper;

		for (let element of list) {
			wrapper = makeWrapper();
			element.parentNode.insertBefore(wrapper, element);
			wrapper.appendChild(element);
		}
	}

Not having made the original script, I'm not sure how it works or what would be required to fix it.

@slime73
Copy link
Member Author

slime73 commented Jan 19, 2022

I've been referencing archive.org for how things used to behave - if that change fixes the "removed in" sections which should be hidden then it's better than before at least, but I can continue poking at it to see if I can find the causes of other issues as well.

[For reference, I don't have the ability/permissions to update the script on the wiki on my own.]

@TheLinx
Copy link
Collaborator

TheLinx commented Jan 19, 2022

Ah, I completely misunderstood the purpose of wrapSections.
It wasn't just gathering all the h2s, it was actually iterating over the elements in between them as well.

The reason the code broke is because the no table of contents plugin broke and I'm hiding it with CSS now, and that's the h2 it's jumping to.
I just updated it to pick a specific h2 and it's behaving correctly now.

I notice that there's a bug with functions that have been added and then later removed.
love2d/love-wiki-version-picker@cf8dc9f#diff-58417e0f781b6656949d37258c8b9052ed266e2eb7a5163cad7b0863e6b2916a
This looks like the culprit.

For now, they'll be appearing when they shouldn't be, but the main issue has been fixed.
Do a hard refresh if you need to.

@slime73
Copy link
Member Author

slime73 commented Jan 19, 2022

Thanks! the newMesh page is working as expected for me now.

I think those added+removed functions had flaky support with the version picker even when they worked with it.

@slime73
Copy link
Member Author

slime73 commented Mar 25, 2022

Something about this broke again apparently. I tried using the version selector on the newMesh page from the original post and it's not doing anything (using Chrome on Windows, if that matters).

I haven't investigated more than that, yet.

EDIT: Firefox seems to work. Strange.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants