fix(elements): detect matchesSelector prototype without IIFE - #37799
CaerusKaru wants to merge 1 commit into
Conversation
11a4b48 to
dad9f6e
Compare
gkalpak
left a comment
There was a problem hiding this comment.
I left a couple of comments. Otherwise lgtm.
Not directly related to this PR:
It seems we have similar (but not 100% the same) code in @angular/animations' shared.ts and @angular/upgrade's downgrade_component_adapter.ts. I wonder if it would make sense to have a shared (internal) utility package for such helpers.
Also, these helpers are not 100% the same. It is hard to tell whether the differences account for slightly different needs of each package and how the helpers are used or whether we should align all implementations 😕
petebacondarwin
left a comment
There was a problem hiding this comment.
Reviewed-for: size-tracking
Not going to block the merge. I guess 600 bytes is not a killer.
But I think it would be good to consider either (or both) of the following:
- Make the
_matchescode easier to understand - Make the
_matchescode smaller
It is likely that these two are in opposition to each other. But I feel that as it stands we have the worst of both scenarios. I feel that it could be smaller or simpler...
Another option, as @gkalpak suggested, is to move this to a shared function, since I imagine that elements is rarely used without animations, in which case we are getting hit twice for this logic. Both of these have core as peer dependency, so it could just be moved there an exported "internally".
There was a problem hiding this comment.
I guess you are using {}.toString.call() because process could feasibly be null?
There was a problem hiding this comment.
This logic seems super complex. Is it to try to keep the code-size down or something else?
There was a problem hiding this comment.
I guess it is just a copy from the animations library.
There was a problem hiding this comment.
I also find this to be super complex.
jelbourn
left a comment
There was a problem hiding this comment.
Would it be possible to add this shim exclusively to server environments rather than always baking it into the client-side lib?
There was a problem hiding this comment.
Can we change this implementation to something like:
angular/packages/upgrade/src/common/src/downgrade_component_adapter.ts
Lines 291 to 300 in d1ea1f4
it's much simpler, and should solve the issue since it's not using an IIFE.
Although in SSR we patch the global prototypes with DOM globals like Element and Node, this patch does not occur before the matches function is called in Angular Elements. This is similar to the behavior in @angular/upgrade. Fixes angular#24551
|
Does this commit fix the |
|
What is the |
Angular Element is not available in SSR. (Below is the issue ticket). |
|
Yes, this PR should have fixed #24551. |
Wow, that's a great news. We can use custom-elements in SSR which was a road block and which release we are making it? |
|
It will be in the next 10.1.x release (10.1.6 - assuming there are going to be more v10 releases before v11) and the next 11.x release (11.0.0-next.6). |
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Although in SSR we patch the global prototypes with DOM globals
like Element and Node, this patch does not occur before the
matches function is called in Angular Elements. This is similar
to the behavior in @angular/upgrade.
Fixes #24551
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Issue Number: 24551
What is the new behavior?
Does this PR introduce a breaking change?
Other information