Skip to content

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

@travisby

Description

@travisby

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions