util: canonicalize namespaced tags in inspect()#63257
Conversation
Signed-off-by: Renegade334 <contact.9a5d6388@renegade334.me.uk>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #63257 +/- ##
=======================================
Coverage 90.03% 90.04%
=======================================
Files 713 713
Lines 224950 224945 -5
Branches 42531 42530 -1
=======================================
+ Hits 202527 202541 +14
+ Misses 14218 14187 -31
- Partials 8205 8217 +12
🚀 New features to boost your workflow:
|
| constructor[endPos] === constructor[endPos].toLowerCase()) { | ||
| result += `[${tag}] `; | ||
| } | ||
| const dot = StringPrototypeLastIndexOf(tag, '.'); |
There was a problem hiding this comment.
I think it is not straightforward to write a class with . in its name, like class Namespace.Class {} is not valid. So we can branch here with the presence of . and keep the original behavior, right?
There was a problem hiding this comment.
As in the previous suppression behaviour?
I really do think that divergent behaviour isn't helpful here – there's no difference between the inheritance models of class MapDerived extends Map and class InstantDerived extends Temporal.Instant, so I can't see that formatting one as a primary class and one as a derived class is at all useful for users.
Precursor to adding support for Temporal objects in #63154.
Namespaced toString tags are becoming more common in ES builtins.
inspect()currently has no logic for dealing with these, leading to rather ugly output:This PR adds logic to handle namespaced tags. If the basename of the namespaced tag matches the constructor name, then it will be treated as the canonical name for that object. Derived classes retain the same behaviour as exists currently.
Note that this replaces, and effectively reverts, some previous logic that existed here from #59687. That PR made partial string tag matches be considered hits, so
FooBarBazwould matchFooand suppress the additional tag output. This logic doesn't really fit with namespaced tags, and I think the easiest approach is just to replace it entirely. (cc @BridgeAR, @miguelmarcondesf)