bugfix: 将a标签替换为button并移除href="#"和事件阻止#910
Merged
Merged
Conversation
- 将TkAdmin、TkComment和TkAction组件中的a标签替换为更语义化的button标签。 - 移除相关事件处理函数中不必要的preventDefault调用
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
修改
将TkAdmin、TkComment和TkAction组件中的a标签替换为更语义化的button标签。
移除相关事件处理函数中不必要的preventDefault调用
解决了什么bug
已经在vitepress环境测试,点击行为正常符合预期,且无需再添加
class="vp-raw"。已修改范围内组件的样式不受影响。
理论上不会再在基于swup的主题中产生异常滚动。
相关Issue
见 #620 ,该issue中首次出现了
href="#"代码及其相关的preventDefault用于解决vitepress中的问题。见 #721 ,该issue提出了在基于swup的主题中异常滚动至顶部,且多人发现移除
href="#"是有效的解决方案。顺带一提,这包括我自己。swup的跳转似乎是其模拟的结果,swup会提取链接的哈希并模拟原生行为进行跳转。当初通过
href="#"解决vitepress的方案在这里产生了不可避免的副作用。见 #832 ,Ercilan提出了使用button的方案,vitepress的源代码显示使用button可以完全规避跳转问题,且不会触发swup的哈希提取。
自行全局替换
href="#"是一种难以持续的方案,很多基于swup的主题(尤其是自使用swup的saicaca/fuwari为主的分支)如matsuzaka-yuki/Mizuki、CuteLeaf/Firefly等等都在用不同方式为此付出额外的时间和代码,我希望能在这里彻底解决它。