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:
vsavkin
2016-02-09 17:46:38 -08:00
committed by Brian Ford
parent 8f47aa3530
commit 50548fb565
4 changed files with 27 additions and 5 deletions
+13 -1
View File
@@ -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); });
});
});
}