-
Notifications
You must be signed in to change notification settings - Fork 337
Closed
Labels
Description
At the moment, when you're on a page with a fragment (anything after the # symbol) and you choose to Write Style For (clicking the entire URL), that fragment is included in the url-prefix. This causes a couple of issues:
- Stylus only activates the style when that exact fragment is present in the URL at the time the page is loaded. Clicking a hyperlink to change the fragment later doesn't include the style. While this makes sense from a technical perspective, it could be seen as undefined/buggy behavior.
- Since the fragment usually isn't visible when clicking Write Style For because it's cropped off the end of the line, this might cause confusion for the author later.
I've provided a simple example style below. If you go to that exact URL the style will work. If you just go to the Wiki page and click 'Setting a Hotkey' in the table of contents, the URL bar shows the fragment but Stylus doesn't activate the style.
I would suggest a quick fix by not including URL fragments when Write Style For is chosen, to avoid these issues, since the author probably doesn't want it. Whether you want Stylus to activate/deactivate styles when the fragment changes... is up to you.
System Information
- OS: Windows 10
- Browser: Firefox 136.0b6
- Stylus Version: 2.3.10
Screenshots, links, CSS
/* ==UserStyle==
@name Github Fragment Test
@namespace github.com/openstyles/stylus
@version 1.0.0
@description A new userstyle
@author Me
==/UserStyle== */
@-moz-document url-prefix("https://github.com/openstyles/stylus/wiki/Colorpicker#setting-a-hotkey") {
.AppHeader-localBar li:nth-child(1) {
background: red;
}
}