Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 5ceb5db

Browse files
thorn0lgalfaso
authored andcommitted
perf(injector): cache the results of the native class detection check
Closes: #14322
1 parent bd7d5f6 commit 5ceb5db

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/auto/injector.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -837,13 +837,16 @@ function createInjector(modulesToLoad, strictDi) {
837837

838838
function isClass(func) {
839839
// IE 9-11 do not support classes and IE9 leaks with the code below.
840-
if (msie <= 11) {
840+
if (msie <= 11 || typeof func !== 'function') {
841841
return false;
842842
}
843-
// Workaround for MS Edge.
844-
// Check https://connect.microsoft.com/IE/Feedback/Details/2211653
845-
return typeof func === 'function'
846-
&& /^(?:class\s|constructor\()/.test(Function.prototype.toString.call(func));
843+
var result = func.$$ngIsClass;
844+
if (!isBoolean(result)) {
845+
// Workaround for MS Edge.
846+
// Check https://connect.microsoft.com/IE/Feedback/Details/2211653
847+
result = func.$$ngIsClass = /^(?:class\s|constructor\()/.test(Function.prototype.toString.call(func));
848+
}
849+
return result;
847850
}
848851

849852
function invoke(fn, self, locals, serviceName) {

0 commit comments

Comments
 (0)