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

Commit 4724d56

Browse files
committed
fix($injector): fix class detection RegExp
Mentioned in #14531 (comment). Closes #14533
1 parent 70fcffc commit 4724d56

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

src/auto/injector.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -853,10 +853,10 @@ function createInjector(modulesToLoad, strictDi) {
853853
if (msie <= 11) {
854854
return false;
855855
}
856-
// Workaround for MS Edge.
857-
// Check https://connect.microsoft.com/IE/Feedback/Details/2211653
856+
// Support: Edge 12-13 only
857+
// See: https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/6156135/
858858
return typeof func === 'function'
859-
&& /^(?:class\s|constructor\()/.test(stringifyFn(func));
859+
&& /^(?:class\b|constructor\()/.test(stringifyFn(func));
860860
}
861861

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

test/auto/injectorSpec.js

+20
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,26 @@ describe('injector', function() {
302302
expect(instance.aVal()).toEqual('a-value');
303303
});
304304

305+
if (/chrome/.test(navigator.userAgent)) {
306+
they('should detect ES6 classes regardless of whitespace/comments ($prop)', [
307+
'class Test {}',
308+
'class Test{}',
309+
'class //<--ES6 stuff\nTest {}',
310+
'class//<--ES6 stuff\nTest {}',
311+
'class {}',
312+
'class{}',
313+
'class //<--ES6 stuff\n {}',
314+
'class//<--ES6 stuff\n {}',
315+
'class/* Test */{}',
316+
'class /* Test */ {}'
317+
], function(classDefinition) {
318+
var Clazz = eval('(' + classDefinition + ')');
319+
var instance = injector.invoke(Clazz);
320+
321+
expect(instance).toEqual(jasmine.any(Clazz));
322+
});
323+
}
324+
305325
// Support: Chrome 50-51 only
306326
// TODO (gkalpak): Remove when Chrome v52 is relased.
307327
// it('should be able to invoke classes', function() {

0 commit comments

Comments
 (0)