State merge/specificity

When multiple behaviors match the same element, VSN merges them based on selector specificity.

State merge rules

  • Events accumulate.
  • State declarations use the most specific selector.
  • Inline vsn-* declarations outrank behavior declarations.

Specificity tie-breaker

If specificity is equal, later behaviors in the source win.

Example

behavior .card { theme: "light"; }
behavior .card.primary { theme: "brand"; }

The .card.primary behavior wins for theme because it’s more specific.