Diagram - Data Attributes

Use rendering identity and state attributes for targeted styles and browser assertions.

#Import

import { Diagram } from '@primeui/vue-diagram';

#Identity Attributes

The viewport renders these attributes on scene surfaces. Use model identities to target an item; keep assertions aware that virtualization can replace rich views with overview geometry.

AttributeSurfaceValue
data-layer-idRendered viewport layerSaved layer ID.
data-entity-idNode, connector and label surfacesSaved owner/entity identity for that surface.
data-node-idNode and node-related handlesSaved node ID.
data-node-typeNodeSaved node type.
data-connector-idConnectorSaved connector ID.
data-label-idLabelSaved label ID.
data-port-idRendered node port circleSaved port ID.
data-diagram-portApplication element with Diagram.PortExisting port ID supplied to the anchor component.

A record’s presence in the store does not guarantee a currently mounted element with its attribute. Reveal an offscreen item before asserting its rich content. Hidden, clipped and collapsed items follow their ownership and visibility rules.

#State and Interaction Attributes

AttributeSurfaceMeaning
data-selectedRich nodeStringified selected state; match ='true' when styling selection.
data-diagram-unavailableUnavailable node-content placeholderThe runtime could not resolve the required content.
data-connection-previewConnection preview SVGAn in-progress connection preview.
data-validConnection previewWhether the preview has no current connection diagnostics.
data-diagram-handle / data-transform-kindTransform handlesHandle identity and transform kind.
data-connection-handle / data-connection-kindConnector handlesHandle identity and edit kind.
data-diagram-interactiveApplication-owned interactive contentPreserve native/application input ownership instead of graph gesture handling.

Canvas aids also expose data-diagram-guide on snap-guide paths, data-drawing-preview on drawing paths and data-pool-preview on swimlane preview SVGs. Live port controls expose data-connection-port and data-connection-node; these identify the port and owning node. Connector handles additionally expose data-axis where applicable and data-compact for compact targets. Use these for scoped presentation, keeping runtime positions and hit areas intact.

Connector selection uses the p-diagram-connector-selected class rather than the node's data-selected attribute. Keyboard focus uses :focus-visible. Use Theming for color precedence and geometry limits.

Attributes identify surfaces and state; they do not authorize edits. Commands and editors still check policy. The copied editor exposes its data-density and dir, and copied preset surfaces use data-preset where declared. They are not a universal data-slot system shared by every Diagram part.

#Styling

Keep theme roles and authored paint ownership in mind when styling a saved item.

.p-diagram-node[data-node-id='review'][data-selected='true'] {
    outline: 2px solid var(--p-diagram-selection);
}

#Testing

After revealing the item, locate its declared identity and assert the behavior that matters.

const review = page.locator('.p-diagram-node[data-node-id="review"]');
await expect(review).toBeVisible();
await expect(review).toHaveAttribute('data-selected', 'true');

This is a browser-test excerpt; page and expect come from the application’s test runner. Avoid using private descendant structure to find controls. Accessible names are preferable when the assertion concerns a user action.