Skip to content

Commit b783738

Browse files
committed
refactor: Remove isDart from public API
BREAKING CHANGE: - `IS_DARTIUM` no longer exported
1 parent 5c328ad commit b783738

35 files changed

Lines changed: 61 additions & 74 deletions

modules/angular2/src/core/application_common.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ import {
77
BaseException,
88
assertionsEnabled,
99
print,
10-
stringify,
11-
isDart
10+
stringify
1211
} from 'angular2/src/facade/lang';
1312
import {BrowserDomAdapter} from 'angular2/src/dom/browser_adapter';
1413
import {DOM} from 'angular2/src/dom/dom_adapter';
@@ -76,6 +75,7 @@ import {
7675
import {internalView} from 'angular2/src/core/compiler/view_ref';
7776
import {APP_COMPONENT_REF_PROMISE, APP_COMPONENT} from './application_tokens';
7877
import {wtfInit} from '../profile/wtf_init';
78+
import {EXCEPTION_BINDING} from './platform_bindings';
7979

8080
var _rootInjector: Injector;
8181

@@ -146,7 +146,7 @@ function _injectorBindings(appComponentType): List<Type | Binding | List<any>> {
146146
PipeResolver,
147147
Parser,
148148
Lexer,
149-
bind(ExceptionHandler).toFactory(() => new ExceptionHandler(DOM, isDart ? false : true), []),
149+
EXCEPTION_BINDING,
150150
bind(XHR).toValue(new XHRImpl()),
151151
ComponentUrlMapper,
152152
UrlResolver,
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
library angular2.platform_bindings;
2+
3+
4+
import 'package:angular2/di.dart';
5+
import './exception_handler.dart';
6+
import 'package:angular2/src/dom/dom_adapter.dart';
7+
8+
exceptionFactory() => new ExceptionHandler(DOM, true);
9+
10+
const EXCEPTION_BINDING = const Binding(ExceptionHandler, toFactory: exceptionFactory, deps: const []);
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import {bind} from 'angular2/di';
2+
import {ExceptionHandler} from './exception_handler';
3+
import {DOM} from 'angular2/src/dom/dom_adapter';
4+
5+
export const EXCEPTION_BINDING =
6+
bind(ExceptionHandler).toFactory(() => new ExceptionHandler(DOM, false), []);

modules/angular2/src/facade/lang.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ import 'dart:math' as math;
55
import 'dart:convert' as convert;
66
import 'dart:async' show Future;
77

8-
bool isDart = true;
9-
108
String getTypeNameForDebugging(Type type) => type.toString();
119

1210
class Math {

modules/angular2/src/facade/lang.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ export function getTypeNameForDebugging(type: Type): string {
1515
return type['name'];
1616
}
1717

18-
export var isDart = false;
19-
2018
export class BaseException extends Error {
2119
stack;
2220
constructor(public message?: string, private _originalException?, private _originalStack?,

modules/angular2/src/test_lib/test_lib.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ import 'package:angular2/src/facade/collection.dart' show StringMapWrapper;
2828
import 'test_injector.dart';
2929
export 'test_injector.dart' show inject;
3030

31-
bool IS_DARTIUM = true;
32-
3331
List _testBindings = [];
3432
Injector _injector;
3533
bool _isCurrentTestAsync;

modules/angular2/src/test_lib/test_lib.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,6 @@ export interface NgMatchers extends jasmine.Matchers {
3333

3434
export var expect: (actual: any) => NgMatchers = <any>_global.expect;
3535

36-
// TODO vsavkin: remove it and use lang/isDart instead
37-
export var IS_DARTIUM = false;
38-
3936
export class AsyncTestCompleter {
4037
_done: Function;
4138

modules/angular2/test/change_detection/change_detector_spec.ts

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,5 @@
11
///<reference path="../../src/change_detection/pipe_transform.ts"/>
2-
import {
3-
ddescribe,
4-
describe,
5-
it,
6-
iit,
7-
xit,
8-
expect,
9-
beforeEach,
10-
afterEach,
11-
IS_DARTIUM
12-
} from 'angular2/test_lib';
2+
import {ddescribe, describe, it, iit, xit, expect, beforeEach, afterEach} from 'angular2/test_lib';
133

144
import {
155
CONST_EXPR,
@@ -51,6 +41,7 @@ import {JitProtoChangeDetector} from 'angular2/src/change_detection/jit_proto_ch
5141

5242
import {getDefinition} from './change_detector_config';
5343
import {getFactoryById} from './generated/change_detector_classes';
44+
import {IS_DART} from '../platform';
5445

5546
const _DEFAULT_CONTEXT = CONST_EXPR(new Object());
5647

@@ -68,8 +59,8 @@ const _DEFAULT_CONTEXT = CONST_EXPR(new Object());
6859
*/
6960
export function main() {
7061
ListWrapper.forEach(['dynamic', 'JIT', 'Pregen'], (cdType) => {
71-
if (cdType == "JIT" && IS_DARTIUM) return;
72-
if (cdType == "Pregen" && !IS_DARTIUM) return;
62+
if (cdType == "JIT" && IS_DART) return;
63+
if (cdType == "Pregen" && !IS_DART) return;
7364

7465
describe(`${cdType} Change Detector`, () => {
7566

@@ -141,7 +132,7 @@ export function main() {
141132
() => { expect(_bindSimpleValue('1 != 1')).toEqual(['propName=false']); });
142133

143134
it('should support == operations on coerceible', () => {
144-
var expectedValue = IS_DARTIUM ? 'false' : 'true';
135+
var expectedValue = IS_DART ? 'false' : 'true';
145136
expect(_bindSimpleValue('1 == true')).toEqual([`propName=${expectedValue}`]);
146137
});
147138

modules/angular2/test/change_detection/parser/parser_spec.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {ddescribe, describe, it, xit, iit, expect, beforeEach, IS_DARTIUM} from 'angular2/test_lib';
1+
import {ddescribe, describe, it, xit, iit, expect, beforeEach} from 'angular2/test_lib';
22
import {BaseException, isBlank, isPresent} from 'angular2/src/facade/lang';
33
import {reflector} from 'angular2/src/reflection/reflection';
44
import {MapWrapper, ListWrapper} from 'angular2/src/facade/collection';
@@ -7,6 +7,7 @@ import {Unparser} from './unparser';
77
import {Lexer} from 'angular2/src/change_detection/parser/lexer';
88
import {Locals} from 'angular2/src/change_detection/parser/locals';
99
import {BindingPipe, LiteralPrimitive, AST} from 'angular2/src/change_detection/parser/ast';
10+
import {IS_DART} from '../../platform';
1011

1112
class TestData {
1213
constructor(public a?: any, public b?: any, public fnReturnValue?: any) {}
@@ -224,7 +225,7 @@ export function main() {
224225
expect(() => { expectEval('null?.a.a', td()).toEqual(null); }).toThrowError();
225226
});
226227

227-
if (!IS_DARTIUM) {
228+
if (!IS_DART) {
228229
it('should return null when accessing a field on undefined', () => {
229230
expect(() => { expectEval('_undefined?.a', td()).toEqual(null); }).not.toThrow();
230231
});

modules/angular2/test/core/application_spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ import {
88
inject,
99
it,
1010
xdescribe,
11-
xit,
12-
IS_DARTIUM
11+
xit
1312
} from 'angular2/test_lib';
1413
import {isPresent, stringify} from 'angular2/src/facade/lang';
1514
import {bootstrap, ApplicationRef} from 'angular2/src/core/application';
@@ -21,6 +20,7 @@ import {LifeCycle} from 'angular2/core';
2120
import {ExceptionHandler} from 'angular2/src/core/exception_handler';
2221
import {Testability, TestabilityRegistry} from 'angular2/src/core/testability/testability';
2322
import {DOCUMENT} from 'angular2/src/render/render';
23+
import {IS_DART} from '../platform';
2424

2525
@Component({selector: 'hello-app'})
2626
@View({template: '{{greeting}} world!'})
@@ -109,7 +109,7 @@ export function main() {
109109

110110
it('should throw if no element is found', inject([AsyncTestCompleter], (async) => {
111111
var logger = new _ArrayLogger();
112-
var exceptionHandler = new ExceptionHandler(logger, IS_DARTIUM ? false : true);
112+
var exceptionHandler = new ExceptionHandler(logger, IS_DART ? false : true);
113113

114114
var refPromise =
115115
bootstrap(HelloRootCmp, [bind(ExceptionHandler).toValue(exceptionHandler)]);
@@ -124,7 +124,7 @@ export function main() {
124124
it('should invoke the default exception handler when bootstrap fails',
125125
inject([AsyncTestCompleter], (async) => {
126126
var logger = new _ArrayLogger();
127-
var exceptionHandler = new ExceptionHandler(logger, IS_DARTIUM ? false : true);
127+
var exceptionHandler = new ExceptionHandler(logger, IS_DART ? false : true);
128128

129129
var refPromise =
130130
bootstrap(HelloRootCmp, [bind(ExceptionHandler).toValue(exceptionHandler)]);

0 commit comments

Comments
 (0)