Respect keyframe definition order

AI assistance disclosure: Codex helped implement and verify this fix under maintainer direction.
This commit is contained in:
Paul Bakaus
2026-09-02 12:06:44 -07:00
parent 7139130f99
commit a0552bba0c
5 changed files with 33 additions and 6 deletions
+5 -3
View File
@@ -1531,7 +1531,7 @@ if (IS_BROWSER) {
const parts = [];
const seen = new Set();
const animationNames = new Set();
const keyframeCandidates = [];
const keyframeCandidates = new Map();
const appendRules = (rules, requiresAppliedMatch = false) => {
for (const rule of rules) {
if (rule.styleSheet) {
@@ -1564,7 +1564,9 @@ if (IS_BROWSER) {
}
const keyframesName = keyframesRuleName(rule, cssText);
if (keyframesName) {
keyframeCandidates.push({
// Keyframes do not merge: when a name is defined more than once, the
// later effective definition replaces the earlier one.
keyframeCandidates.set(keyframesName, {
name: keyframesName,
cssText,
});
@@ -1602,7 +1604,7 @@ if (IS_BROWSER) {
// animation renders. The live reference is the useful gate: it preserves
// linked marquee/pulse detection without letting unreferenced keyframe
// bodies feed page-level checks.
for (const candidate of keyframeCandidates) {
for (const candidate of keyframeCandidates.values()) {
if (!animationNames.has(candidate.name)) continue;
parts.push(candidate.cssText);
}