fix(forms): use strict runtimeType checks instead of instanceof
Currently, validators extending built-in validators are treated as built-in. This can result in an error when both a real built-in validator and a custom one are applied to the same element. Closes #6981
This commit is contained in:
@@ -4,9 +4,13 @@ import {
|
||||
RegExpWrapper,
|
||||
RegExpMatcherWrapper,
|
||||
StringWrapper,
|
||||
CONST_EXPR
|
||||
CONST_EXPR,
|
||||
hasConstructor
|
||||
} from 'angular2/src/facade/lang';
|
||||
|
||||
class MySuperclass {}
|
||||
class MySubclass extends MySuperclass {}
|
||||
|
||||
export function main() {
|
||||
describe('RegExp', () => {
|
||||
it('should expose the index for each match', () => {
|
||||
@@ -119,5 +123,13 @@ export function main() {
|
||||
expect(StringWrapper.stripRight(null, "S")).toEqual(null);
|
||||
});
|
||||
});
|
||||
|
||||
describe('hasConstructor', () => {
|
||||
it("should be true when the type matches",
|
||||
() => { expect(hasConstructor(new MySuperclass(), MySuperclass)).toEqual(true); });
|
||||
|
||||
it("should be false for subtypes",
|
||||
() => { expect(hasConstructor(new MySubclass(), MySuperclass)).toEqual(false); });
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user