Beispiel
dom-accessibility-api 0.6.3: computeAccessibleName
Verifiziertes Beispiel für npm dom-accessibility-api 0.6.3: computeAccessibleName. Der Vertrag lief auf node 22 · linux debian/x64 · docker und bestand.
sha256:a4e723cde7fefd3513e82cef220febcfa63068871a953f88389a48d53c9c60ff
Dieses Netzwerk bietet eine Sache: ein Sample, das baut. Es hat es in einer Sandbox ausgeführt und die signierte Quittung behalten. Es bewertet nichts und garantiert nichts — ob derselbe Code bei Ihnen baut, hat es nicht gemessen.
Wie viele verschiedene Signaturschlüssel eine bestandene Vertragsquittung eingereicht haben. Einer ist der Autor allein; mehr als einer heißt, jemand anderes hat es auch gebaut. Ein Schlüssel wird selbst erzeugt und hat keine registrierte Identität dahinter — gezählt werden Schlüssel, nicht Personen.
MIT-0
Ausführungsbelege
Die deklarierte Umgebung und die signierten Läufe stehen getrennt, damit Sie genau sehen, was dieses Sample ausgeführt hat und wo.
- Beleggrundlage
- Signierter Vertrag bestanden
- Verifizierungsbelege
- 1
- Signaturschlüssel, die es gebaut haben
- 1
Deklarierte Umgebung
node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10
Umgebungen der Verifizierungsläufe
| Umgebung | Contract | Stufen | Lauf |
|---|---|---|---|
| node 22 · linux debian/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1node:22@sha256:8a34c4ab3ea2… |
2026-09-06 |
Fall
HOW- Ziel
- verify dom-accessibility-api.computeAccessibleName in pkg:npm/dom-accessibility-api@0.6.3
- Pakete
- Symbole
-
- dom-accessibility-api.computeAccessibleName
- Umgebung
- node 22.23.2
- Erstellt
- 2026-09-06T14:31:46Z
Contract
- computeAccessibleName resolves accessible name from aria-label with highest precedence over text content
- computeAccessibleName resolves accessible name from element subtree text
- computeAccessibleName resolves accessible name referencing other elements via aria-labelledby
- computeAccessibleName resolves accessible name referencing multiple elements via space-separated aria-labelledby IDs
- computeAccessibleName returns empty string for elements with generic role that prohibit naming
- computeAccessibleName resolves accessible name from input element using aria-label
Dateien
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- src/index.js
- test/contract.mjs
Quelltext
Clean-room public code sample — generation instructions
Write a brand-new, minimal, self-contained code sample in this clean-room directory.
Do not copy, paraphrase, or reference any existing project source. Work only from this spec.
A csx.json manifest scaffold already exists. Do not recreate it from memory. Preserve its case.goal, packages and symbols; fill its empty case.contract with exact assertions and correct its environment, commands and verifierAdapter for the files you generate.
Goal: verify dom-accessibility-api.computeAccessibleName in pkg:npm/dom-accessibility-api@0.6.3
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/dom-accessibility-api@0.6.3
Demonstrate these symbols/APIs:
- dom-accessibility-api.computeAccessibleName
Rules:
- One focused purpose; the smallest project that proves the goal.
- Include a contract test (test/contract.*) that runs OFFLINE and exits 0 exactly when the goal behavior works.
- Pin every dependency with a lockfile so resolution is reproducible.
- No secrets, credentials, or tokens. No real URLs (only example.com or localhost). No absolute paths.
- No personal names, emails, company names, or project identifiers of any kind.
- No binaries and no generated output (node_modules, dist, target, venv, .git, .env).
- Keep it under 200 files and 256KB packed.
{"case":{"caseId":"case:sha256:951aceb6804586de08ffd986379403b302f02b91ac72628c9ac0edb8d5b97553","contract":["computeAccessibleName resolves accessible name from aria-label with highest precedence over text content","computeAccessibleName resolves accessible name from element subtree text","computeAccessibleName resolves accessible name referencing other elements via aria-labelledby","computeAccessibleName resolves accessible name referencing multiple elements via space-separated aria-labelledby IDs","computeAccessibleName returns empty string for elements with generic role that prohibit naming","computeAccessibleName resolves accessible name from input element using aria-label"],"goal":"verify dom-accessibility-api.computeAccessibleName in pkg:npm/dom-accessibility-api@0.6.3","kind":"HOW","packages":["pkg:npm/dom-accessibility-api@0.6.3"],"schemaVersion":1,"symbols":["dom-accessibility-api.computeAccessibleName"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","executionContext":"node","language":"javascript","libc":"glibc","libcVersion":"2.39","moduleSystem":"esm","os":"linux","osVersionBucket":"24","packageManager":"npm","packageManagerVersion":"10.9.8","runtime":"node","runtimeVersion":"22.23.2","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/dom-accessibility-api@0.6.3"],"schemaVersion":1,"subject":"pkg:npm/dom-accessibility-api@0.6.3","symbols":["dom-accessibility-api.computeAccessibleName"],"verifierAdapter":"node-typescript@1"}
{
"name": "sample-dom-accessibility-api",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-dom-accessibility-api",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"dom-accessibility-api": "0.6.3"
}
},
"node_modules/dom-accessibility-api": {
"version": "0.6.3",
"resolved": "https://registry.npmjs.org/dom-accessibility-api/-/dom-accessibility-api-0.6.3.tgz",
"integrity": "sha512-7ZgogeTnjuHbo+ct10G9Ffp0mif17idi0IyWNVA/wcwcm7NPOD/WEHVP3n7n3MhXqxoIYm8d6MuZohYWIZ4T3w==",
"license": "MIT"
}
}
}
{
"name": "sample-dom-accessibility-api",
"version": "1.0.0",
"private": true,
"type": "module",
"description": "Clean-room verification for dom-accessibility-api computeAccessibleName",
"main": "src/index.js",
"scripts": {
"test": "node test/contract.mjs"
},
"dependencies": {
"dom-accessibility-api": "0.6.3"
},
"license": "MIT-0"
}
{
"schemaVersion": 1,
"goal": "verify dom-accessibility-api.computeAccessibleName in pkg:npm/dom-accessibility-api@0.6.3",
"kind": "HOW",
"packages": [
"pkg:npm/dom-accessibility-api@0.6.3"
],
"symbols": [
"dom-accessibility-api.computeAccessibleName"
]
}
import { computeAccessibleName } from 'dom-accessibility-api';
/**
* Creates a lightweight DOM Element node suitable for accessibility calculations in headless environments.
* @param {string} tagName
* @param {Record<string, string>} [attributes={}]
* @param {Array<string | object>} [children=[]]
* @param {Map<string, object>} [registry]
* @param {Record<string, string>} [styles={}]
* @returns {object}
*/
export function createMockElement(tagName, attributes = {}, children = [], registry = new Map(), styles = {}) {
const attrs = new Map(Object.entries(attributes));
const styleMap = new Map(Object.entries(styles));
const mockDoc = {
defaultView: {
getComputedStyle: (node) => {
if (node && node.getComputedStyle) {
return node.getComputedStyle();
}
return {
getPropertyValue: () => '',
};
},
},
getElementById: (id) => registry.get(id) ?? null,
querySelectorAll: () => [],
};
const element = {
nodeType: 1, // ELEMENT_NODE
ELEMENT_NODE: 1,
TEXT_NODE: 3,
tagName: tagName.toUpperCase(),
localName: tagName.toLowerCase(),
ownerDocument: mockDoc,
childNodes: [],
getComputedStyle() {
return {
getPropertyValue: (prop) => styleMap.get(prop) ?? '',
};
},
getAttribute(name) {
return attrs.get(name) ?? null;
},
getAttributeNode(name) {
if (!attrs.has(name)) return null;
return { value: attrs.get(name) };
},
hasAttribute(name) {
return attrs.has(name);
},
querySelectorAll() {
return [];
},
};
if (attributes.id) {
registry.set(attributes.id, element);
}
element.childNodes = children.map((child) => {
if (typeof child === 'string') {
return {
nodeType: 3, // TEXT_NODE
ELEMENT_NODE: 1,
TEXT_NODE: 3,
textContent: child,
ownerDocument: mockDoc,
childNodes: [],
parentNode: element,
};
}
child.parentNode = element;
return child;
});
return element;
}
/**
* Computes the accessible name for a DOM element.
* @param {object} element
* @param {object} [options]
* @returns {string}
*/
export function getAccessibleName(element, options) {
return computeAccessibleName(element, options);
}
export { computeAccessibleName };
import assert from 'node:assert/strict';
import {
computeAccessibleName,
createMockElement,
getAccessibleName,
} from '../src/index.js';
// 1. computeAccessibleName resolves accessible name from aria-label with highest precedence over text content
const ariaLabelBtn = createMockElement('button', { 'aria-label': 'Close Window' }, ['X']);
assert.equal(computeAccessibleName(ariaLabelBtn), 'Close Window', 'aria-label must take precedence over text content');
assert.equal(getAccessibleName(ariaLabelBtn), 'Close Window', 'helper function returns identical result');
// 2. computeAccessibleName resolves accessible name from element subtree text
const textButton = createMockElement('button', {}, [
createMockElement('span', {}, ['Save']),
' ',
createMockElement('span', {}, ['Document']),
]);
assert.equal(computeAccessibleName(textButton), 'Save Document', 'accessible name must accumulate subtree text');
// 3. computeAccessibleName resolves accessible name referencing other elements via aria-labelledby
const registry1 = new Map();
const labelEl = createMockElement('span', { id: 'title-id' }, ['Billing Section'], registry1);
const sectionEl = createMockElement('section', { 'aria-labelledby': 'title-id' }, [], registry1);
assert.equal(computeAccessibleName(sectionEl), 'Billing Section', 'aria-labelledby must resolve referenced element text');
// 4. computeAccessibleName resolves accessible name referencing multiple elements via space-separated aria-labelledby IDs
const registry2 = new Map();
const firstPart = createMockElement('span', { id: 'part-one' }, ['Primary'], registry2);
const lastPart = createMockElement('span', { id: 'part-two' }, ['Action'], registry2);
const container = createMockElement('div', { role: 'group', 'aria-labelledby': 'part-one part-two' }, [], registry2);
assert.equal(computeAccessibleName(container), 'Primary Action', 'aria-labelledby must join multiple referenced elements');
// 5. computeAccessibleName returns empty string for elements with generic role that prohibit naming
const genericWithAriaLabel = createMockElement('div', { role: 'generic', 'aria-label': 'Forbidden Name' });
assert.equal(computeAccessibleName(genericWithAriaLabel), '', 'generic role prohibits accessible name');
// 6. computeAccessibleName resolves accessible name from input element using aria-label
const ariaLabelInput = createMockElement('input', { type: 'text', 'aria-label': 'Search Query' });
assert.equal(computeAccessibleName(ariaLabelInput), 'Search Query', 'aria-label on input must be returned');
console.log('All contract assertions passed successfully.');
Ursprungs-Seeder
anonym