Commit-Queue | +1 |
Hey all, here's the last big CL for the scoped registry for now. It implements the logic relating to cross document adoption of a node and how we take care of the registry in these scenarios.
Some note:
PTAL, thanks!
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
bool explicit_set = false);
want to add a comment here explaining what explicit_set does?
std::optional<CustomElementRegistry*> GetCustomElementRegistry() const;
want to add a comment here explaining the difference between nullptr and nullopt?
// We intentionally don't use SetField function because SetField will erase
I don't understand this... if we aren't supposed to be using SetField, then why is SetField being called here?
// Custom element registry of a tree scope can only be set once except the tree
except when the?
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Generally looks good, just some concerns about the `nullptr` vs. `nullopt` thing.
CustomElementRegistry* EffectiveGlobalCustomElementRegistry() const;
This could use a comment explaining what it is (i.e. what "effective" means). I don't love the name either - maybe something closer to `CustomElementRegistryIfGlobal()` or something? I don't know.
// If the registry is the same as the tree scope's registry, we typically
// can clear the registry field in rare data and have the registry implicitly
Does this break in some circumstances? E.g. is there some way to later insert an element in between this one and the root, which uses a custom registry, and have that take effect for this element?
// inferred. There are certain scenarios where we want the registry to be
+1 to Joey's comment - it'd be good to enumerate those scenarios.
std::optional<CustomElementRegistry*> GetCustomElementRegistry() const;
want to add a comment here explaining the difference between nullptr and nullopt?
Yeah +1 to this. I'd perhaps go a step further and split it into two methods. One like `bool HasCustomElementRegistrySet()` that is used instead of `std::optional`, and then this one that does `DCHECK(HasCustomElementRegistrySet())` (so you only call it when you've already checked it), and then just returns the pointer. That's a lot easier to keep track of in your head, I think.
if (fields_.HasField(FieldId::kCustomElementRegistry)) {
return static_cast<CustomElementRegistry*>(
fields_.GetField(FieldId::kCustomElementRegistry).Get());
}
// Return nullopt to signify that the field has never been set.
Yeah, the logic around nullptr vs. nullopt is really hard to wrap your head around.
if (GetField(FieldId::kCustomElementRegistry)) {
DCHECK(static_cast<CustomElementRegistry*>(
GetField(FieldId::kCustomElementRegistry))
->IsGlobalRegistry());
}
Better not to have DCHECK-only code inside an `if`. Perhaps this instead?
```
DCHECK(!GetField(FieldId::kCustomElementRegistry) ||
static_cast<CustomElementRegistry*>(
GetField(FieldId::kCustomElementRegistry))
->IsGlobalRegistry());
```
// We intentionally don't use SetField function because SetField will erase
I don't understand this... if we aren't supposed to be using SetField, then why is SetField being called here?
I think he means ElementRareDataVector::SetField, rather than the one on `fields_`.
// the field if we set null to the field. However, there are scenarios where
Again, good to enumerate scenarios.
// keep track of it in case the registry is implicitly implied by the
nit: `implicitly implied` -> `implied`
But really this comment is a little hard to parse, if there's anything that can be simplified/clarified?
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |