@layer revert-layer Cascade Order Lookup

Resolve revert-layer within caller ordered declared layers, importance reverses layer order; origin/unlayered/specificity competition must already be resolved externally. Explicit supplied computed/layout context only; not a browser cascade/layout engine or cross-browser guarantee.

Description

Cascade layers have ordering rules that differ for normal and important declarations.

Cascade layers have ordering rules that differ for normal and important declarations.1

A supplied rollback trace does not execute the complete cascade across origins and declarations. Use @layer revert-layer Cascade Order Lookup to evaluate the supplied inputs under the specific model below.

When to use @layer revert-layer Cascade Order Lookup

Use @layer revert-layer Cascade Order Lookup to evaluate the supplied inputs under the specific model below. Define the supplied layout, token or rendering scenario and establish the relevant units and browser context independently.

How to use @layer revert-layer Cascade Order Lookup and understand its results

  1. Define the supplied layout, token or rendering scenario and establish the relevant units and browser context independently.
  2. Enter Caller ordered layer names, Caller winning tokens, Current layer index, Important declaration using the field table and validation rules below, then run the tool.
  3. Read Resolved prior layer token, Selected layer index and interpret units, signs, ordering and placeholders as explained below.
  4. If the tool reports an input error, correct that field and rerun. A successful false result, empty match list or unknown-evidence placeholder has the specific meaning described here; check the limitations before applying the result.
Input fieldMeaningValue typeRequirement
callerOrderedLayerNamesCaller ordered layer namesarray of stringRequired; constraints below
callerWinningTokensCaller winning tokensarray of stringRequired; constraints below
currentLayerIndexCurrent layer indexnumberRequired; constraints below
importantDeclarationImportant declarationbooleanRequired; constraints below

Enter unique nonblank layer IDs, aligned winning-token strings, a valid zero-based current-layer index containing exactly revert-layer and an important-declaration flag. Normal declarations search toward decreasing layer indices; important declarations search toward increasing indices. Skip additional revert-layer tokens and return the first ordinary supplied token. Exhausting the supplied layers is an error. The caller must supply the correct layer order and preselected layer winners; unlayered rules, origins and full cascade competition are outside the model.

step = important ? +1 : −1; winner = first non-revert-layer token reached from currentIndex+step

Field order, units and branch conditions follow the implementation explanation above.

Output fieldMeaningValue type
resolvedPriorLayerTokenResolved prior layer tokenstring
selectedLayerIndexSelected layer indexnumber
json
{
  "input": {
    "callerOrderedLayerNames": [
      "base",
      "theme",
      "local"
    ],
    "callerWinningTokens": [
      "black",
      "blue",
      "revert-layer"
    ],
    "currentLayerIndex": 2,
    "importantDeclaration": false
  },
  "output": {
    "resolvedPriorLayerToken": "blue",
    "selectedLayerIndex": 1
  }
}

Limitations and assumptions

Layer priority reverses for important declarations. The local search direction here assumes layer winners and order have already been established.2

A supplied rollback trace does not execute the complete cascade across origins and declarations. Apply the exact scope and assumptions described above.

All listed fields require explicit values. Unexpected fields, incorrect types, nonfinite numbers and sparse arrays fail validation. Domain-specific bounds, alignments and supported tokens are stated above; extremely large inputs or outputs can also be rejected. These errors differ from successful results such as false, no matches or unknown evidence.

Alternative or Complementary methods

Use inherit/initial/unset/revert Resolution Table for a related task: CSS-wide keywords choose parent, initial or rollback values under defined rules.

Use contain Strictness Levels Lookup for a related task: Containment separates selected effects on layout, painting, sizing and style.

References

  1. @layer revert-layer Cascade Order Lookup — tool.io

  2. CSS Cascading and Inheritance Level 5 — W3C

Similar or alternative tools

Don't forget to set a bookmark for tool.io!
Privacy | Imprint | Cookies