Rename Op discriminant to directive, open() name to id#20
Merged
Conversation
commit: |
88d2168 to
77cc2bf
Compare
Restructures the Op type so the discriminant field is `directive` instead of `id`, freeing `id` for the element identity string. The `name` parameter on `open()` and `OpenElement` becomes `id`, aligning with Clay's terminology. Drops the `idx++` seed from Clay_HashString — element IDs are now hashed with seed 0 and uniqueness is the caller's responsibility. Duplicate IDs within a frame are undefined behavior. Removes INV-7 (element identity disambiguation) from the spec and updates Sections 8.3.1, 9.3, and 10.3 accordingly. Closes #16
77cc2bf to
ee7f5bc
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
The
open()parameter is callednamebut it functions as an element identity for Clay's layout engine (Clay_ElementId). Meanwhile, theidfield on Op types is a numeric discriminant, creating a naming collision. See #16.Additionally, the renderer was using an auto-incrementing seed (
idx++) when hashing element IDs, making it impossible for callers to look up elements by name after layout — a prerequisite for exposing computed dimensions.Approach
Op type restructuring:
idtodirectiveon all Op interfaces (OpenElement,Text,CloseElement)open()'snameparameter toid, and theOpenElement.namefield toOpenElement.idpack(),validate.ts, and all tests to use the new field namesID hashing:
Clay__HashString(str, idx++)toClay__HashString(str, 0)— element IDs are now hashed with a constant seedSpec updates:
Closes #16