<t-scope>

Gives part of the page its own set of variables.

Without any <t-scope>, all elements on a page share one page-wide set of variables. Every element inside a <t-scope> uses that scope's variables instead, so the same names can mean different things in different places:

Alice runs 5 km at 5.5 min/km: minutes.

Bob runs 10 km at 6 min/km: minutes.

When to use it

Behavior

From JavaScript

Get a scope with scopeOf(element), using any element inside it, or from the scope property of the <t-scope> itself:

import { scopeOf } from "/tangle.js";

const alice = scopeOf(document.querySelector("#alice"));
alice.set("km", 21.1);

const page = scopeOf(document); // the page-wide scope

See the JavaScript API for what a scope can do.