You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
This doesn't currently work right since Angular illegally calls
the constructor via apply() without "new". Known Angular issue:
angular/angular.js#12597
klausw
added a commit
to GoogleCloudPlatform/PerfKitExplorer
that referenced
this issue
Oct 1, 2015
This doesn't currently work right since Angular illegally calls
the constructor via apply() without "new". Known Angular issue:
angular/angular.js#12597
@mprobst I've encountered the similar issue before and ended up by splitting the solution into separate extension, ng-classified.
Just have checked #12598, I have a feeling that patching up instantiate is halfhearted job, it will just affect performance by propagating new everywhere and not targeting the classes. And other things that could benefit from classes will still get their TypeErrors (the world is bigger than controllers).
It is evident that I've managed it more drastically, it is $injector.invoke which is primarily responsible for calling class constructors directly. And I consider it the right idea to fix it there because it is a great opportunity to pull up mature 1.x to fit contemporary expectations (particularly excited by Angular 2) by using DI-enabled classes everywhere where 1.x would expect constructor functions, without breaking anything.
It's not that simple, what's good for extension, is bad for framework. Due to the fact that only Chrome/V8 native class implementation can be easily detected (even FF native classes appear as functions for now), I've had to introduce some conventions and add flag checks to avoid trying-catching TypeErrors on every invoke.
Is it acceptable to make $injector configurable on framework level? I'm not sure at all. But I think it is inevitable to provide some degree of configurability to deal with classes in future-proof manner while keeping the performance high for classless apps.
This code (paraphrasing) fails with
TypeError: Class constructors cannot be invoked without 'new'
:The reason is that ES6 disallows using
fn.apply
on class constructors.The text was updated successfully, but these errors were encountered: