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

Switcher switches the first link in header, even if it is not a CSS link #58

Open
travisby opened this issue Sep 9, 2024 · 1 comment

Comments

@travisby
Copy link

travisby commented Sep 9, 2024

Hello!

I spent a few minutes debugging why the CSS dropin wasn't working for me. After reading the code, I understood what went wrong a little better:

https://github.com/dohliam/dropin-minimal-css/blob/6cc6f0ba0cfb046ecf1a52125be53536b6f2f73f/switcher.js#L39C2-L40

does...

function add_switcher() {
  css_link = document.getElementsByTagName("link")[0];
  if (css_link == undefined) {
...

My page looks like:

...
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Hello, World!</title>
  <meta name="description" content="Home page">
  <link rel="icon" type="image/svg+xml" href="https://dohliam.github.io/dropin-minimal-css/min/a11yana.min.css">
  <style></style>
</head>
...

Namely, the first link element is a favicon, not a CSS stylesheet!

In my case, it would be better to follow the logic for if the link was undefined.

I was able to mitigate this with <link rel="stylesheet" href="" /> at the top of my head to get by!

@ivoba
Copy link

ivoba commented Oct 18, 2024

I got into the same situation, with having the first link being a a print css with media=print.

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