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

css.at-rules.starting-style - Safari only applies rule on load and not on new elements added to the DOM #25643

Open
eli-fusionary opened this issue Jan 13, 2025 · 0 comments
Labels
data:css Compat data for CSS features. https://developer.mozilla.org/docs/Web/CSS

Comments

@eli-fusionary
Copy link

eli-fusionary commented Jan 13, 2025

What type of issue is this?

Browser bug (a bug with a feature that may impact site compatibility)

What information was incorrect, unhelpful, or incomplete?

Safari is reported to support this but I do not believe it does.

What browsers does this problem apply to, if applicable?

Safari (I am using 17.6)

What did you expect to see?

When I added a square to the DOM, it should have applied the @starting-styles. It did not. It did apply them on load, but not on add.

Did you test this? If so, how?

I tested it by running this code through Live Server within Safari and Chrome. You will want to pull it up then navigate to the /transitions page. This is part of a course I am taking on Udemy.

Can you link to any release notes, bugs, pull requests, or MDN pages related to this?

No, I think Safari is probably a private repo. Here is the MDN page though: https://developer.mozilla.org/en-US/docs/Web/CSS/@starting-style

Do you have anything more you want to share?

.square {
  width: 100px;
  height: 100px;
  background-image: linear-gradient(purple, yellow);
  transition: display 0.5s allow-discrete, opacity 0.5s, transform 0.5s;
}

@starting-style {
  .square {
    opacity: 0;
    transform: scale(0);
  }
}

.square.hide {
  display: none;
  opacity: 0;
}
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Transitions</title>
    <link rel="stylesheet" href="styles.css" />
    <script>
      document.addEventListener("DOMContentLoaded", () => {
        const element = document.querySelector(".square");
        const addButton = document.querySelector(".add-square");

        addButton.addEventListener("click", () => {
          const newSquare = document.createElement("div");
          newSquare.classList.add("square");
          document.querySelector(".wrapper").appendChild(newSquare);
        });
      });
    </script>
  </head>
  <body>
    <div class="wrapper">
      <div class="square"></div>
    </div>
    <button class="add-square">Add Square</button>
  </body>
</html>
starting-styles-safari-chrome.mov

MDN URL

https://developer.mozilla.org/en-US/docs/Web/CSS/@starting-style

MDN metadata

MDN page report details
  • Query: css.at-rules.starting-style
  • Report started: 2025-01-13T18:37:06.489Z
@github-actions github-actions bot added the data:css Compat data for CSS features. https://developer.mozilla.org/docs/Web/CSS label Jan 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
data:css Compat data for CSS features. https://developer.mozilla.org/docs/Web/CSS
Projects
None yet
Development

No branches or pull requests

1 participant