-
Notifications
You must be signed in to change notification settings - Fork 561
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce ElementsEnhancer and elementId #23562
Conversation
06c294a
to
38ec01f
Compare
PRbuilds results: Screenshots 💚 A11y validation 💚 Microdata Validation Apache Benchmark Load Testing LightHouse Reporting --automated message |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
renderId doesn't itself have real semantics for backend types
I also think this in more in line with what we're calling this. renderId
means that this is the id given at render time and it will change change at each render
Seen on PROD (merged by @shtukas 17 minutes and 36 seconds ago)
|
Introduction
trait PageElement
and its members model the objects the backend send to DCR for rendering. In the DCR data object, they are referred to asBlockElement
s, for instanceThe State of PageElement Identifiers
BlockElement
do not per se have a neturally defined identifier. This is because although some of them correspond to CAPI elements who have a natural identifer, for instance atoms, PageElements are more general than content held in CAPI.Due to historical reasons a few
PageElement
s have a field calledid
, for instancebut this
id
should be seen as metadata about the original data the PageElement represents.In Feb 2021, the DCR team requested that PageElements be given an identifier that would help with rendering, notably to be used for DOM reconciliation during React rendering. Although DCR itself could be responsible to provide them (ultil this point it actually did using integer indices), the backend accepted to provide one, called
elementId
.We then moved to serving, say,
TextBlockElement
like this:to this:
NB:
The backend type
trait PageElement
, does not itself enforces the presence ofelementId
, this attribute is added (at the time these lines are written), as per this Introduce ElementsEnhancer and elementId #23562 , using a data enhancer applied to the JSON representation of the DCR data object. This choice was made on the basis that theelementId
is a courtesy provided to DCR by the backend and not a real property of the data as seen by the backendThe initial implementation uses UUIDs, but the contract is that any reasonably unique string can do
The value of
elementId
for each element is, as per original implementation, randomly chosen at each generation. In any case, there is no 1-2-1 mapping betweenPageElement
s /BlockElement
s and those values.