fix: angular detection can be less blunt#1687
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
| +*/ | ||
| +function angularZoneUnpatchedAlternative$1(key) { | ||
| + const angularUnpatchedVersionSymbol = ( | ||
| + globalThis |
There was a problem hiding this comment.
angular puts a function on Zone you can call with the name of the thing
and you get back undefined or where it has stored the thing
| + angularUnpatchedVersionSymbol && | ||
| + (globalThis)[angularUnpatchedVersionSymbol] | ||
| + ) { | ||
| + return (globalThis)[ |
There was a problem hiding this comment.
so, if there's an unpatched version we can use that
(confirmed this returns expected values on customer site)
| if (untaintedBasePrototype$1[key]) | ||
| return untaintedBasePrototype$1[key]; | ||
| - const defaultObj = globalThis[key]; | ||
| + const defaultObj = angularZoneUnpatchedAlternative$1(key) || globalThis[key]; |
There was a problem hiding this comment.
so we use the angular one if its present or the default global
even if this was an expensive lookup (it's not) the results are cached
| +You can rename Zone, but this is a good enough proxy to avoid going to an iframe to get the untainted versions. | ||
| +see: https://github.com/angular/angular/issues/26948 | ||
| +*/ | ||
| +function angularZoneUnpatchedAlternative(key) { |
There was a problem hiding this comment.
same here because we're patching a bundle that is tree-shaken badly
| ) | ||
| ); | ||
| - if (isUntaintedAccessors && isUntaintedMethods && !isAngularZonePresent$1()) { | ||
| + if (isUntaintedAccessors && isUntaintedMethods) { |
There was a problem hiding this comment.
and so no angular check here
|
Size Change: +2.47 kB (+0.08%) Total Size: 3.28 MB
ℹ️ View Unchanged
|
daibhin
left a comment
There was a problem hiding this comment.
Feels like it couldn't hurt 😅 Given this is an Angular specific issue I think it's relatively safe to test it out
| }; | ||
| +/* | ||
| +Angular zone patches many things and can pass the untainted checks below, causing performance issues | ||
| +Angular zone, puts the unpatched originals on the window, and the names for hose on the zone object. |
There was a problem hiding this comment.
| +Angular zone, puts the unpatched originals on the window, and the names for hose on the zone object. | |
| +Angular zone, puts the unpatched originals on the window, and the names for those on the zone object. |
from investigation of how rrweb has done this over time and how safari behaves with different versions manually patched
i learned that Angular Zone advertises its unpatched versions in a known/discoverable location
let's just use them instead of going to an iframe when they're present