Kalabasa / htmz

html with targeted manipulation zones

Home Page:http://leanrada.com/htmz/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Breaks links to subheadings

Jak2k opened this issue · comments

Many websites give their subheadings an id and then make it or a ToC link to the subheading. This allows to send a link to a specific subheading. Your script breaks that.

Do you mean link to an id in the same page?

The links can can to the same page or can link sections of other pages.

Sorry, I don't quite follow. Could you give an example to help me understand? Thank you.

When <base target=htmz> is set like in you examples, links will not work.

Ah yes! You should not use base if you wish to do that.

Then the example is missleading, because in real usage you would need to write target on every link that uses htmz.

Maybe a custom attribute and a little bit more JS would make sense, as the size of the hundrets of target=htmz would be bigger than a slightly bigger script.

You would likely need attributes on links to make them async with some other library too. For example, htmx has its hx-* attributes, turbo has its data-turbo attributes.

Both are several kb in size so it would take a very large number of links to get to that size too.

You could write a small amount of JavaScript to automatically add target=html to your non-in-page links in that scenario too.

If you have just a handful of in-page links, you could also use target="_self".

If you have only a few interactive bits for htmz, then use target="htmz".

<base> a bit like the with statement in JS - use with care.

I used it in the example because it made sense there. Real usage varies, so you can implement what is appropriate for your use-case, but I don't think the base snippet can assume how it's gonna be used.

The above suggestion with JS sounds good too, if that's what your page needs.

Let's say we add a custom attribute, then we would have to continually watch and parse the DOM for that attribute, or attach a global click listener... then maybe we would have to worry about Ctrl+Click incompatibility, or some other incompatibility. Probably exaggerating, but it would potentially cause more breakage. Maybe we'd have to resort to a generic JS API like htmz.process(your_dom) to handle all the cases.

As for the original issue, it doesn't seem like the htmz snippet itself breaks in-page links, so I'll close this issue. Let me know if you want to discuss further - there are discussions of extensions in this repo's Discussion tab.