When StyleRules are parented to a StyleSheet (or another StyleRule) they have this behavior where their priority is automatically set to the lowest integer not currently taken by another StyleSheet sibling. This behavior is useful as it allows more recently added StyleSheets to have more precedence.
However this behavior also affects priorities which have been manually set before the StyleRule was parented. If the StyleSheet’s priority has been changed from its default then it should not be automatically changed when said StyleRule is parented.
Code to demonstrate the issue further:
local Sheet = Instance.new("StyleSheet")
Sheet.Parent = workspace
local RuleA = Instance.new("StyleRule")
RuleA.Name = "RuleA [4]"
RuleA.Priority = 4 -- This will be overwritten to `0`.
RuleA.Parent = Sheet
local RuleB = Instance.new("StyleRule")
RuleB.Name = "RuleB [3]"
RuleB.Priority = 3 -- This will be overwritten to `1`.
RuleB.Parent = Sheet
As you can see I wanted RuleA to have a priority of 4, and RuleB a priority of 3 but due to this behavior my explicitly defined intentions are disregarded by the behavior I outlined above.
Of course I could set the priority after parenting, or I could change the order of which I parent the Instances - but these are merely workarounds, not solutions to the problem.
Expected behavior
I would expect that if the priority was changed from its default then it should not be changed when parenting the StyleRule.