From 8343fb7740ca7f8b3b1e38dff6460ed34f566aa9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mi=C5=A1ko=20Hevery?= Date: Thu, 2 Mar 2017 09:37:01 -0800 Subject: [PATCH] refactor: remove lang.ts (#14837) --- modules/@angular/benchpress/src/facade | 1 - .../src/reporter/console_reporter.ts | 10 +- modules/@angular/benchpress/src/runner.ts | 9 +- modules/@angular/benchpress/src/sampler.ts | 5 +- .../src/webdriver/firefox_driver_extension.ts | 3 +- .../src/webdriver/ios_driver_extension.ts | 9 +- .../test/metric/perflog_metric_spec.ts | 9 +- .../test/reporter/console_reporter_spec.ts | 3 +- .../test/reporter/json_file_reporter_spec.ts | 3 +- .../@angular/benchpress/test/sampler_spec.ts | 12 +-- .../benchpress/test/trace_event_factory.ts | 3 +- .../test/web_driver_extension_spec.ts | 3 +- .../webdriver/chrome_driver_extension_spec.ts | 3 +- .../common/src/directives/ng_class.ts | 3 +- .../common/src/directives/ng_for_of.ts | 6 +- modules/@angular/common/src/facade | 1 - .../src/location/hash_location_strategy.ts | 5 +- .../src/location/path_location_strategy.ts | 5 +- .../@angular/common/src/pipes/date_pipe.ts | 4 +- .../src/pipes/invalid_pipe_argument_error.ts | 4 +- .../@angular/common/src/pipes/number_pipe.ts | 23 ++-- .../common/test/pipes/number_pipe_spec.ts | 21 ++++ modules/@angular/common/testing/facade | 1 - modules/@angular/compiler/src/assertions.ts | 7 +- .../@angular/compiler/src/compile_metadata.ts | 18 ++-- .../src/compiler_util/expression_converter.ts | 7 +- .../compiler/src/css_parser/css_lexer.ts | 11 +- .../compiler/src/css_parser/css_parser.ts | 23 ++-- .../compiler/src/directive_normalizer.ts | 4 +- .../compiler/src/directive_resolver.ts | 4 +- .../compiler/src/expression_parser/ast.ts | 3 +- .../compiler/src/expression_parser/lexer.ts | 11 +- .../compiler/src/expression_parser/parser.ts | 19 ++-- modules/@angular/compiler/src/facade | 1 - modules/@angular/compiler/src/jit/compiler.ts | 3 +- .../compiler/src/metadata_resolver.ts | 4 +- .../@angular/compiler/src/ml_parser/parser.ts | 11 +- .../compiler/src/ng_module_compiler.ts | 11 +- .../compiler/src/ng_module_resolver.ts | 3 +- .../compiler/src/output/abstract_emitter.ts | 11 +- .../src/output/abstract_js_emitter.ts | 7 +- .../compiler/src/output/js_emitter.ts | 3 +- .../compiler/src/output/output_ast.ts | 5 +- .../compiler/src/output/output_interpreter.ts | 11 +- .../compiler/src/output/ts_emitter.ts | 11 +- modules/@angular/compiler/src/parse_util.ts | 5 +- .../@angular/compiler/src/pipe_resolver.ts | 3 +- .../compiler/src/provider_analyzer.ts | 27 +++-- .../src/template_parser/template_parser.ts | 13 ++- modules/@angular/compiler/src/url_resolver.ts | 27 +++-- modules/@angular/compiler/src/util.ts | 13 ++- .../test/css_parser/css_lexer_spec.ts | 3 +- .../test/css_parser/css_visitor_spec.ts | 1 - .../test/expression_parser/parser_spec.ts | 13 ++- .../test/i18n/serializers/xliff_spec.ts | 2 +- .../test/i18n/serializers/xtb_spec.ts | 3 +- .../compiler/test/metadata_resolver_spec.ts | 4 +- .../compiler/test/ng_module_resolver_spec.ts | 2 +- .../compiler/test/pipe_resolver_spec.ts | 2 +- .../test/resource_loader_mock_spec.ts | 5 +- .../compiler/test/runtime_compiler_spec.ts | 4 +- modules/@angular/compiler/test/util_spec.ts | 11 +- .../testing/directive_resolver_mock.ts | 9 +- modules/@angular/compiler/testing/facade | 1 - .../compiler/testing/metadata_overrider.ts | 2 +- .../compiler/testing/resource_loader_mock.ts | 3 +- modules/@angular/core/src/application_ref.ts | 5 +- .../src/change_detection/change_detection.ts | 2 +- .../change_detection/change_detection_util.ts | 26 +++-- .../core/src/change_detection/constants.ts | 3 +- .../differs/default_iterable_differ.ts | 4 +- .../differs/default_keyvalue_differ.ts | 3 +- .../differs/iterable_differs.ts | 9 +- modules/@angular/core/src/console.ts | 11 +- .../@angular/core/src/core_private_export.ts | 2 +- modules/@angular/core/src/di/forward_ref.ts | 3 +- modules/@angular/core/src/di/injector.ts | 2 +- .../@angular/core/src/di/reflective_errors.ts | 2 +- .../@angular/core/src/di/reflective_key.ts | 3 +- modules/@angular/core/src/facade | 1 - .../src/linker/component_factory_resolver.ts | 2 +- .../core/src/linker/ng_module_factory.ts | 3 +- .../src/reflection/reflection_capabilities.ts | 7 +- modules/@angular/core/src/util.ts | 29 ++++- modules/@angular/core/src/util/decorators.ts | 3 +- modules/@angular/core/src/view/text.ts | 2 +- modules/@angular/core/src/view/util.ts | 4 +- .../core/test/di/reflective_injector_spec.ts | 5 +- .../core/test/facade/observable_spec.ts | 63 ----------- .../core/test/linker/integration_spec.ts | 3 +- .../test/linker/ng_module_integration_spec.ts | 2 +- .../test/linker/query_integration_spec.ts | 2 +- .../@angular/core/test/zone/ng_zone_spec.ts | 3 +- modules/@angular/core/testing/facade | 1 - modules/@angular/core/testing/test_bed.ts | 3 +- .../examples/facade/ts/async/observable.ts | 19 ---- .../facade/ts/async/observable_patched.ts | 21 ---- .../facade/ts/async/observable_pure.ts | 20 ---- modules/@angular/facade/src/lang.ts | 102 ------------------ modules/@angular/facade/test/lang_spec.ts | 43 -------- .../select_control_value_accessor.ts | 7 +- .../select_multiple_control_value_accessor.ts | 7 +- .../@angular/forms/src/directives/shared.ts | 11 +- modules/@angular/forms/src/facade | 1 - modules/@angular/forms/src/form_builder.ts | 5 +- modules/@angular/forms/src/validators.ts | 7 +- .../@angular/forms/test/form_array_spec.ts | 3 +- .../@angular/forms/test/form_control_spec.ts | 3 +- .../@angular/forms/test/form_group_spec.ts | 3 +- .../platform-browser-dynamic/src/facade | 1 - .../resource_loader/resource_loader_impl.ts | 1 - .../platform-browser-dynamic/testing/facade | 1 - .../src/browser/browser_adapter.ts | 28 +++-- .../src/browser/generic_browser_adapter.ts | 9 +- .../src/browser/testability.ts | 3 +- .../src/browser/tools/browser.ts} | 5 +- .../src/browser/tools/common_tools.ts | 15 ++- .../platform-browser/src/dom/debug/by.ts | 3 +- .../platform-browser/src/dom/dom_renderer.ts | 4 - modules/@angular/platform-browser/src/facade | 1 - .../platform-browser/src/private_export.ts | 1 + .../test/browser/bootstrap_spec.ts | 4 +- .../test/testing_public_spec.ts | 4 +- .../@angular/platform-browser/testing/facade | 1 - modules/@angular/platform-server/src/facade | 1 - .../platform-server/src/parse5_adapter.ts | 13 ++- .../platform-server/src/server_renderer.ts | 6 +- .../@angular/platform-server/testing/facade | 1 - .../platform-webworker-dynamic/src/facade | 1 - .../@angular/platform-webworker/src/facade | 1 - .../shared/client_message_broker.ts | 5 +- .../src/web_workers/shared/serializer.ts | 5 +- .../shared/web_worker_test_util.ts | 5 +- modules/@angular/router/testing/facade | 1 - modules/@angular/upgrade/src/facade | 1 - .../upgrade/src/static/upgrade_component.ts | 4 +- .../src/old/compiler/selector_benchmark.ts | 1 - .../src/old/naive_infinite_scroll/app.ts | 4 +- tools/@angular/tsc-wrapped/src/collector.ts | 5 +- 139 files changed, 406 insertions(+), 676 deletions(-) delete mode 120000 modules/@angular/benchpress/src/facade delete mode 120000 modules/@angular/common/src/facade delete mode 120000 modules/@angular/common/testing/facade delete mode 120000 modules/@angular/compiler/src/facade delete mode 120000 modules/@angular/compiler/testing/facade delete mode 120000 modules/@angular/core/src/facade delete mode 100644 modules/@angular/core/test/facade/observable_spec.ts delete mode 120000 modules/@angular/core/testing/facade delete mode 100644 modules/@angular/examples/facade/ts/async/observable.ts delete mode 100644 modules/@angular/examples/facade/ts/async/observable_patched.ts delete mode 100644 modules/@angular/examples/facade/ts/async/observable_pure.ts delete mode 100644 modules/@angular/facade/src/lang.ts delete mode 100644 modules/@angular/facade/test/lang_spec.ts delete mode 120000 modules/@angular/forms/src/facade delete mode 120000 modules/@angular/platform-browser-dynamic/src/facade delete mode 120000 modules/@angular/platform-browser-dynamic/testing/facade rename modules/@angular/{examples/facade/ts/async/observable_all.ts => platform-browser/src/browser/tools/browser.ts} (69%) delete mode 120000 modules/@angular/platform-browser/src/facade delete mode 120000 modules/@angular/platform-browser/testing/facade delete mode 120000 modules/@angular/platform-server/src/facade delete mode 120000 modules/@angular/platform-server/testing/facade delete mode 120000 modules/@angular/platform-webworker-dynamic/src/facade delete mode 120000 modules/@angular/platform-webworker/src/facade delete mode 120000 modules/@angular/router/testing/facade delete mode 120000 modules/@angular/upgrade/src/facade diff --git a/modules/@angular/benchpress/src/facade b/modules/@angular/benchpress/src/facade deleted file mode 120000 index e084c803c6..0000000000 --- a/modules/@angular/benchpress/src/facade +++ /dev/null @@ -1 +0,0 @@ -../../facade/src \ No newline at end of file diff --git a/modules/@angular/benchpress/src/reporter/console_reporter.ts b/modules/@angular/benchpress/src/reporter/console_reporter.ts index 7867fcddfd..72fd545175 100644 --- a/modules/@angular/benchpress/src/reporter/console_reporter.ts +++ b/modules/@angular/benchpress/src/reporter/console_reporter.ts @@ -7,7 +7,6 @@ */ import {Inject, Injectable, InjectionToken} from '@angular/core'; -import {print} from '../facade/lang'; import {MeasureValues} from '../measure_values'; import {Reporter} from '../reporter'; import {SampleDescription} from '../sample_description'; @@ -23,8 +22,13 @@ export class ConsoleReporter extends Reporter { static PRINT = new InjectionToken('ConsoleReporter.print'); static COLUMN_WIDTH = new InjectionToken('ConsoleReporter.columnWidth'); static PROVIDERS = [ - ConsoleReporter, {provide: ConsoleReporter.COLUMN_WIDTH, useValue: 18}, - {provide: ConsoleReporter.PRINT, useValue: print} + ConsoleReporter, {provide: ConsoleReporter.COLUMN_WIDTH, useValue: 18}, { + provide: ConsoleReporter.PRINT, + useValue: function(v: any) { + // tslint:disable-next-line:no-console + console.log(v); + } + } ]; private static _lpad(value: string, columnWidth: number, fill = ' ') { diff --git a/modules/@angular/benchpress/src/runner.ts b/modules/@angular/benchpress/src/runner.ts index 6624590af2..97a188f4d5 100644 --- a/modules/@angular/benchpress/src/runner.ts +++ b/modules/@angular/benchpress/src/runner.ts @@ -9,7 +9,6 @@ import {Provider, ReflectiveInjector} from '@angular/core'; import {Options} from './common_options'; -import {isPresent} from './facade/lang'; import {Metric} from './metric'; import {MultiMetric} from './metric/multi_metric'; import {PerflogMetric} from './metric/perflog_metric'; @@ -49,16 +48,16 @@ export class Runner { _DEFAULT_PROVIDERS, this._defaultProviders, {provide: Options.SAMPLE_ID, useValue: id}, {provide: Options.EXECUTE, useValue: execute} ]; - if (isPresent(prepare)) { + if (prepare != null) { sampleProviders.push({provide: Options.PREPARE, useValue: prepare}); } - if (isPresent(microMetrics)) { + if (microMetrics != null) { sampleProviders.push({provide: Options.MICRO_METRICS, useValue: microMetrics}); } - if (isPresent(userMetrics)) { + if (userMetrics != null) { sampleProviders.push({provide: Options.USER_METRICS, useValue: userMetrics}); } - if (isPresent(providers)) { + if (providers != null) { sampleProviders.push(providers); } diff --git a/modules/@angular/benchpress/src/sampler.ts b/modules/@angular/benchpress/src/sampler.ts index 7e43f8d420..14e7206f58 100644 --- a/modules/@angular/benchpress/src/sampler.ts +++ b/modules/@angular/benchpress/src/sampler.ts @@ -9,7 +9,6 @@ import {Inject, Injectable} from '@angular/core'; import {Options} from './common_options'; -import {isPresent} from './facade/lang'; import {MeasureValues} from './measure_values'; import {Metric} from './metric'; import {Reporter} from './reporter'; @@ -38,7 +37,7 @@ export class Sampler { sample(): Promise { const loop = (lastState: SampleState): Promise => { return this._iterate(lastState).then((newState) => { - if (isPresent(newState.validSample)) { + if (newState.validSample != null) { return newState; } else { return loop(newState); @@ -68,7 +67,7 @@ export class Sampler { const completeSample = state.completeSample.concat([measureValues]); const validSample = this._validator.validate(completeSample); let resultPromise = this._reporter.reportMeasureValues(measureValues); - if (isPresent(validSample)) { + if (validSample != null) { resultPromise = resultPromise.then((_) => this._reporter.reportSample(completeSample, validSample)); } diff --git a/modules/@angular/benchpress/src/webdriver/firefox_driver_extension.ts b/modules/@angular/benchpress/src/webdriver/firefox_driver_extension.ts index e59c751edc..6dcb8c601c 100644 --- a/modules/@angular/benchpress/src/webdriver/firefox_driver_extension.ts +++ b/modules/@angular/benchpress/src/webdriver/firefox_driver_extension.ts @@ -8,7 +8,6 @@ import {Injectable} from '@angular/core'; -import {isPresent} from '../facade/lang'; import {WebDriverAdapter} from '../web_driver_adapter'; import {PerfLogEvent, PerfLogFeatures, WebDriverExtension} from '../web_driver_extension'; @@ -35,7 +34,7 @@ export class FirefoxDriverExtension extends WebDriverExtension { timeEnd(name: string, restartName: string = null): Promise { let script = 'window.markEnd("' + name + '");'; - if (isPresent(restartName)) { + if (restartName != null) { script += 'window.markStart("' + restartName + '");'; } return this._driver.executeScript(script); diff --git a/modules/@angular/benchpress/src/webdriver/ios_driver_extension.ts b/modules/@angular/benchpress/src/webdriver/ios_driver_extension.ts index effdd8b3b3..8557923cb3 100644 --- a/modules/@angular/benchpress/src/webdriver/ios_driver_extension.ts +++ b/modules/@angular/benchpress/src/webdriver/ios_driver_extension.ts @@ -8,7 +8,6 @@ import {Injectable} from '@angular/core'; -import {isBlank, isPresent} from '../facade/lang'; import {WebDriverAdapter} from '../web_driver_adapter'; import {PerfLogEvent, PerfLogFeatures, WebDriverExtension} from '../web_driver_extension'; @@ -26,7 +25,7 @@ export class IOsDriverExtension extends WebDriverExtension { timeEnd(name: string, restartName: string = null): Promise { let script = `console.timeEnd('${name}');`; - if (isPresent(restartName)) { + if (restartName != null) { script += `console.time('${restartName}');`; } return this._driver.executeScript(script); @@ -76,10 +75,10 @@ export class IOsDriverExtension extends WebDriverExtension { endEvent = createEndEvent('render', endTime); } // Note: ios used to support GCEvent up until iOS 6 :-( - if (isPresent(record['children'])) { + if (record['children'] != null) { this._convertPerfRecordsToEvents(record['children'], events); } - if (isPresent(endEvent)) { + if (endEvent != null) { events.push(endEvent); } }); @@ -104,7 +103,7 @@ function createEvent( // the perflog... 'pid': 'pid0' }; - if (isPresent(args)) { + if (args != null) { result['args'] = args; } return result; diff --git a/modules/@angular/benchpress/test/metric/perflog_metric_spec.ts b/modules/@angular/benchpress/test/metric/perflog_metric_spec.ts index a160e0885e..49841e0d20 100644 --- a/modules/@angular/benchpress/test/metric/perflog_metric_spec.ts +++ b/modules/@angular/benchpress/test/metric/perflog_metric_spec.ts @@ -10,7 +10,6 @@ import {Provider} from '@angular/core'; import {AsyncTestCompleter, beforeEach, describe, expect, inject, it} from '@angular/core/testing/testing_internal'; import {Metric, Options, PerfLogEvent, PerfLogFeatures, PerflogMetric, ReflectiveInjector, WebDriverExtension} from '../../index'; -import {isPresent} from '../../src/facade/lang'; import {TraceEventFactory} from '../trace_event_factory'; export function main() { @@ -48,16 +47,16 @@ export function main() { useValue: new MockDriverExtension(perfLogs, commandLog, perfLogFeatures) } ]; - if (isPresent(forceGc)) { + if (forceGc != null) { providers.push({provide: Options.FORCE_GC, useValue: forceGc}); } - if (isPresent(captureFrames)) { + if (captureFrames != null) { providers.push({provide: Options.CAPTURE_FRAMES, useValue: captureFrames}); } - if (isPresent(receivedData)) { + if (receivedData != null) { providers.push({provide: Options.RECEIVED_DATA, useValue: receivedData}); } - if (isPresent(requestCount)) { + if (requestCount != null) { providers.push({provide: Options.REQUEST_COUNT, useValue: requestCount}); } return ReflectiveInjector.resolveAndCreate(providers).get(PerflogMetric); diff --git a/modules/@angular/benchpress/test/reporter/console_reporter_spec.ts b/modules/@angular/benchpress/test/reporter/console_reporter_spec.ts index da334fcc23..f0f577a751 100644 --- a/modules/@angular/benchpress/test/reporter/console_reporter_spec.ts +++ b/modules/@angular/benchpress/test/reporter/console_reporter_spec.ts @@ -10,7 +10,6 @@ import {Provider} from '@angular/core'; import {describe, expect, it} from '@angular/core/testing/testing_internal'; import {ConsoleReporter, MeasureValues, ReflectiveInjector, SampleDescription} from '../../index'; -import {isBlank, isPresent} from '../../src/facade/lang'; export function main() { describe('console reporter', () => { @@ -38,7 +37,7 @@ export function main() { }, {provide: ConsoleReporter.PRINT, useValue: (line: string) => log.push(line)} ]; - if (isPresent(columnWidth)) { + if (columnWidth != null) { providers.push({provide: ConsoleReporter.COLUMN_WIDTH, useValue: columnWidth}); } reporter = ReflectiveInjector.resolveAndCreate(providers).get(ConsoleReporter); diff --git a/modules/@angular/benchpress/test/reporter/json_file_reporter_spec.ts b/modules/@angular/benchpress/test/reporter/json_file_reporter_spec.ts index c99d3a34a7..193458f44b 100644 --- a/modules/@angular/benchpress/test/reporter/json_file_reporter_spec.ts +++ b/modules/@angular/benchpress/test/reporter/json_file_reporter_spec.ts @@ -9,7 +9,6 @@ import {AsyncTestCompleter, describe, expect, inject, it} from '@angular/core/testing/testing_internal'; import {JsonFileReporter, MeasureValues, Options, ReflectiveInjector, SampleDescription} from '../../index'; -import {isPresent} from '../../src/facade/lang'; export function main() { describe('file reporter', () => { @@ -50,7 +49,7 @@ export function main() { [mv(0, 0, {'a': 3, 'b': 6})], [mv(0, 0, {'a': 3, 'b': 6}), mv(1, 1, {'a': 5, 'b': 9})]); const regExp = /somePath\/someId_\d+\.json/; - expect(isPresent(loggedFile['filename'].match(regExp))).toBe(true); + expect(loggedFile['filename'].match(regExp) != null).toBe(true); const parsedContent = JSON.parse(loggedFile['content']); expect(parsedContent).toEqual({ 'description': { diff --git a/modules/@angular/benchpress/test/sampler_spec.ts b/modules/@angular/benchpress/test/sampler_spec.ts index 7a87d8687e..4542527384 100644 --- a/modules/@angular/benchpress/test/sampler_spec.ts +++ b/modules/@angular/benchpress/test/sampler_spec.ts @@ -9,7 +9,6 @@ import {AsyncTestCompleter, describe, expect, inject, it} from '@angular/core/testing/testing_internal'; import {MeasureValues, Metric, Options, ReflectiveInjector, Reporter, Sampler, Validator, WebDriverAdapter} from '../index'; -import {isBlank, isPresent} from '../src/facade/lang'; export function main() { const EMPTY_EXECUTE = () => {}; @@ -32,7 +31,7 @@ export function main() { if (!reporter) { reporter = new MockReporter([]); } - if (isBlank(driver)) { + if (driver == null) { driver = new MockDriverAdapter([]); } const providers = [ @@ -41,7 +40,7 @@ export function main() { {provide: Options.EXECUTE, useValue: execute}, {provide: Validator, useValue: validator}, {provide: Options.NOW, useValue: () => new Date(time++)} ]; - if (isPresent(prepare)) { + if (prepare != null) { providers.push({provide: Options.PREPARE, useValue: prepare}); } @@ -227,7 +226,7 @@ function createCountingMetric(log: any[] = []) { class MockDriverAdapter extends WebDriverAdapter { constructor(private _log: any[] = [], private _waitFor: Function = null) { super(); } waitFor(callback: Function): Promise { - if (isPresent(this._waitFor)) { + if (this._waitFor != null) { return this._waitFor(callback); } else { return Promise.resolve(callback()); @@ -239,8 +238,7 @@ class MockDriverAdapter extends WebDriverAdapter { class MockValidator extends Validator { constructor(private _log: any[] = [], private _validate: Function = null) { super(); } validate(completeSample: MeasureValues[]): MeasureValues[] { - const stableSample = - isPresent(this._validate) ? this._validate(completeSample) : completeSample; + const stableSample = this._validate != null ? this._validate(completeSample) : completeSample; this._log.push(['validate', completeSample, stableSample]); return stableSample; } @@ -253,7 +251,7 @@ class MockMetric extends Metric { return Promise.resolve(null); } endMeasure(restart: boolean) { - const measureValues = isPresent(this._endMeasure) ? this._endMeasure() : {}; + const measureValues = this._endMeasure != null ? this._endMeasure() : {}; this._log.push(['endMeasure', restart, measureValues]); return Promise.resolve(measureValues); } diff --git a/modules/@angular/benchpress/test/trace_event_factory.ts b/modules/@angular/benchpress/test/trace_event_factory.ts index f6ba2441fe..11ce4c0b53 100644 --- a/modules/@angular/benchpress/test/trace_event_factory.ts +++ b/modules/@angular/benchpress/test/trace_event_factory.ts @@ -7,7 +7,6 @@ */ import {PerfLogEvent} from '../index'; -import {isPresent} from '../src/facade/lang'; export class TraceEventFactory { constructor(private _cat: string, private _pid: string) {} @@ -15,7 +14,7 @@ export class TraceEventFactory { create(ph: any, name: string, time: number, args: any = null) { const res: PerfLogEvent = {'name': name, 'cat': this._cat, 'ph': ph, 'ts': time, 'pid': this._pid}; - if (isPresent(args)) { + if (args != null) { res['args'] = args; } return res; diff --git a/modules/@angular/benchpress/test/web_driver_extension_spec.ts b/modules/@angular/benchpress/test/web_driver_extension_spec.ts index 3609100d32..c6666e159c 100644 --- a/modules/@angular/benchpress/test/web_driver_extension_spec.ts +++ b/modules/@angular/benchpress/test/web_driver_extension_spec.ts @@ -9,7 +9,6 @@ import {AsyncTestCompleter, describe, expect, inject, it} from '@angular/core/testing/testing_internal'; import {Options, ReflectiveInjector, WebDriverExtension} from '../index'; -import {isPresent} from '../src/facade/lang'; export function main() { function createExtension(ids: any[], caps: any) { @@ -41,7 +40,7 @@ export function main() { it('should throw if there is no match', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { createExtension(['m1'], {'browser': 'm2'}).catch((err) => { - expect(isPresent(err)).toBe(true); + expect(err != null).toBe(true); async.done(); }); })); diff --git a/modules/@angular/benchpress/test/webdriver/chrome_driver_extension_spec.ts b/modules/@angular/benchpress/test/webdriver/chrome_driver_extension_spec.ts index 4d379ea44b..8e1958fe5a 100644 --- a/modules/@angular/benchpress/test/webdriver/chrome_driver_extension_spec.ts +++ b/modules/@angular/benchpress/test/webdriver/chrome_driver_extension_spec.ts @@ -9,7 +9,6 @@ import {AsyncTestCompleter, describe, expect, inject, it} from '@angular/core/testing/testing_internal'; import {ChromeDriverExtension, Options, ReflectiveInjector, WebDriverAdapter, WebDriverExtension} from '../../index'; -import {isBlank} from '../../src/facade/lang'; import {TraceEventFactory} from '../trace_event_factory'; export function main() { @@ -38,7 +37,7 @@ export function main() { if (!perfRecords) { perfRecords = []; } - if (isBlank(userAgent)) { + if (userAgent == null) { userAgent = CHROME45_USER_AGENT; } log = []; diff --git a/modules/@angular/common/src/directives/ng_class.ts b/modules/@angular/common/src/directives/ng_class.ts index 03d987f8bc..0d685802e1 100644 --- a/modules/@angular/common/src/directives/ng_class.ts +++ b/modules/@angular/common/src/directives/ng_class.ts @@ -6,8 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -import {Directive, DoCheck, ElementRef, Input, IterableChanges, IterableDiffer, IterableDiffers, KeyValueChanges, KeyValueDiffer, KeyValueDiffers, Renderer, ɵisListLikeIterable as isListLikeIterable} from '@angular/core'; -import {stringify} from '../facade/lang'; +import {Directive, DoCheck, ElementRef, Input, IterableChanges, IterableDiffer, IterableDiffers, KeyValueChanges, KeyValueDiffer, KeyValueDiffers, Renderer, ɵisListLikeIterable as isListLikeIterable, ɵstringify as stringify} from '@angular/core'; /** * @ngModule CommonModule diff --git a/modules/@angular/common/src/directives/ng_for_of.ts b/modules/@angular/common/src/directives/ng_for_of.ts index 3bb141f8a2..93f04f7c2f 100644 --- a/modules/@angular/common/src/directives/ng_for_of.ts +++ b/modules/@angular/common/src/directives/ng_for_of.ts @@ -8,8 +8,6 @@ import {ChangeDetectorRef, Directive, DoCheck, EmbeddedViewRef, Input, IterableChangeRecord, IterableChanges, IterableDiffer, IterableDiffers, NgIterable, OnChanges, SimpleChanges, TemplateRef, TrackByFunction, ViewContainerRef, forwardRef, isDevMode} from '@angular/core'; -import {getTypeNameForDebugging} from '../facade/lang'; - export class NgForOfRow { constructor(public $implicit: T, public index: number, public count: number) {} @@ -195,3 +193,7 @@ export type NgFor = NgForOf; * @deprecated from v4.0.0 - Use NgForOf instead. */ export const NgFor = NgForOf; + +export function getTypeNameForDebugging(type: any): string { + return type['name'] || typeof type; +} diff --git a/modules/@angular/common/src/facade b/modules/@angular/common/src/facade deleted file mode 120000 index e084c803c6..0000000000 --- a/modules/@angular/common/src/facade +++ /dev/null @@ -1 +0,0 @@ -../../facade/src \ No newline at end of file diff --git a/modules/@angular/common/src/location/hash_location_strategy.ts b/modules/@angular/common/src/location/hash_location_strategy.ts index 07d4332700..66c5f707bc 100644 --- a/modules/@angular/common/src/location/hash_location_strategy.ts +++ b/modules/@angular/common/src/location/hash_location_strategy.ts @@ -8,7 +8,6 @@ import {Inject, Injectable, Optional} from '@angular/core'; -import {isPresent} from '../facade/lang'; import {Location} from './location'; import {APP_BASE_HREF, LocationStrategy} from './location_strategy'; @@ -40,7 +39,7 @@ export class HashLocationStrategy extends LocationStrategy { private _platformLocation: PlatformLocation, @Optional() @Inject(APP_BASE_HREF) _baseHref?: string) { super(); - if (isPresent(_baseHref)) { + if (_baseHref != null) { this._baseHref = _baseHref; } } @@ -56,7 +55,7 @@ export class HashLocationStrategy extends LocationStrategy { // the hash value is always prefixed with a `#` // and if it is empty then it will stay empty let path = this._platformLocation.hash; - if (!isPresent(path)) path = '#'; + if (path == null) path = '#'; return path.length > 0 ? path.substring(1) : path; } diff --git a/modules/@angular/common/src/location/path_location_strategy.ts b/modules/@angular/common/src/location/path_location_strategy.ts index b734958286..d3ccf7ecfe 100644 --- a/modules/@angular/common/src/location/path_location_strategy.ts +++ b/modules/@angular/common/src/location/path_location_strategy.ts @@ -8,7 +8,6 @@ import {Inject, Injectable, Optional} from '@angular/core'; -import {isBlank} from '../facade/lang'; import {Location} from './location'; import {APP_BASE_HREF, LocationStrategy} from './location_strategy'; @@ -51,11 +50,11 @@ export class PathLocationStrategy extends LocationStrategy { @Optional() @Inject(APP_BASE_HREF) href?: string) { super(); - if (isBlank(href)) { + if (href == null) { href = this._platformLocation.getBaseHrefFromDOM(); } - if (isBlank(href)) { + if (href == null) { throw new Error( `No base href set. Please provide a value for the APP_BASE_HREF token or add a base element to the document.`); } diff --git a/modules/@angular/common/src/pipes/date_pipe.ts b/modules/@angular/common/src/pipes/date_pipe.ts index bbc65e6184..4a212e0dad 100644 --- a/modules/@angular/common/src/pipes/date_pipe.ts +++ b/modules/@angular/common/src/pipes/date_pipe.ts @@ -7,9 +7,9 @@ */ import {Inject, LOCALE_ID, Pipe, PipeTransform} from '@angular/core'; -import {NumberWrapper} from '../facade/lang'; import {DateFormatter} from './intl'; import {invalidPipeArgumentError} from './invalid_pipe_argument_error'; +import {isNumeric} from './number_pipe'; const ISO8601_DATE_REGEX = /^(\d{4})-?(\d\d)-?(\d\d)(?:T(\d\d)(?::?(\d\d)(?::?(\d\d)(?:\.(\d+))?)?)?(Z|([+-])(\d\d):?(\d\d))?)?$/; @@ -111,7 +111,7 @@ export class DatePipe implements PipeTransform { if (isDate(value)) { date = value; - } else if (NumberWrapper.isNumeric(value)) { + } else if (isNumeric(value)) { date = new Date(parseFloat(value)); } else if (typeof value === 'string' && /^(\d{4}-\d{1,2}-\d{1,2})$/.test(value)) { /** diff --git a/modules/@angular/common/src/pipes/invalid_pipe_argument_error.ts b/modules/@angular/common/src/pipes/invalid_pipe_argument_error.ts index 156491080f..92add35e0b 100644 --- a/modules/@angular/common/src/pipes/invalid_pipe_argument_error.ts +++ b/modules/@angular/common/src/pipes/invalid_pipe_argument_error.ts @@ -6,9 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -import {Type} from '@angular/core'; - -import {stringify} from '../facade/lang'; +import {Type, ɵstringify as stringify} from '@angular/core'; export function invalidPipeArgumentError(type: Type, value: Object) { return Error(`InvalidPipeArgument: '${value}' for pipe '${stringify(type)}'`); diff --git a/modules/@angular/common/src/pipes/number_pipe.ts b/modules/@angular/common/src/pipes/number_pipe.ts index 9d129ba1bd..221d3c642c 100644 --- a/modules/@angular/common/src/pipes/number_pipe.ts +++ b/modules/@angular/common/src/pipes/number_pipe.ts @@ -7,9 +7,6 @@ */ import {Inject, LOCALE_ID, Pipe, PipeTransform, Type} from '@angular/core'; - -import {NumberWrapper} from '../facade/lang'; - import {NumberFormatStyle, NumberFormatter} from './intl'; import {invalidPipeArgumentError} from './invalid_pipe_argument_error'; @@ -21,7 +18,7 @@ function formatNumber( if (value == null) return null; // Convert strings to numbers - value = typeof value === 'string' && NumberWrapper.isNumeric(value) ? +value : value; + value = typeof value === 'string' && isNumeric(value) ? +value : value; if (typeof value !== 'number') { throw invalidPipeArgumentError(pipe, value); } @@ -42,13 +39,13 @@ function formatNumber( throw new Error(`${digits} is not a valid digit info for number pipes`); } if (parts[1] != null) { // min integer digits - minInt = NumberWrapper.parseIntAutoRadix(parts[1]); + minInt = parseIntAutoRadix(parts[1]); } if (parts[3] != null) { // min fraction digits - minFraction = NumberWrapper.parseIntAutoRadix(parts[3]); + minFraction = parseIntAutoRadix(parts[3]); } if (parts[5] != null) { // max fraction digits - maxFraction = NumberWrapper.parseIntAutoRadix(parts[5]); + maxFraction = parseIntAutoRadix(parts[5]); } } @@ -162,3 +159,15 @@ export class CurrencyPipe implements PipeTransform { symbolDisplay); } } + +function parseIntAutoRadix(text: string): number { + const result: number = parseInt(text); + if (isNaN(result)) { + throw new Error('Invalid integer literal when parsing ' + text); + } + return result; +} + +export function isNumeric(value: any): boolean { + return !isNaN(value - parseFloat(value)); +} diff --git a/modules/@angular/common/test/pipes/number_pipe_spec.ts b/modules/@angular/common/test/pipes/number_pipe_spec.ts index e0e1c012e1..030f8e2051 100644 --- a/modules/@angular/common/test/pipes/number_pipe_spec.ts +++ b/modules/@angular/common/test/pipes/number_pipe_spec.ts @@ -7,6 +7,7 @@ */ import {CurrencyPipe, DecimalPipe, PercentPipe} from '@angular/common'; +import {isNumeric} from '@angular/common/src/pipes/number_pipe'; import {beforeEach, describe, expect, it} from '@angular/core/testing/testing_internal'; import {browserDetection} from '@angular/platform-browser/testing/browser_util'; @@ -80,6 +81,26 @@ export function main() { () => { expect(() => pipe.transform(new Object())).toThrowError(); }); }); }); + + describe('isNumeric', () => { + it('should return true when passing correct numeric string', + () => { expect(isNumeric('2')).toBe(true); }); + + it('should return true when passing correct double string', + () => { expect(isNumeric('1.123')).toBe(true); }); + + it('should return true when passing correct negative string', + () => { expect(isNumeric('-2')).toBe(true); }); + + it('should return true when passing correct scientific notation string', + () => { expect(isNumeric('1e5')).toBe(true); }); + + it('should return false when passing incorrect numeric', + () => { expect(isNumeric('a')).toBe(false); }); + + it('should return false when passing parseable but non numeric', + () => { expect(isNumeric('2a')).toBe(false); }); + }); }); } diff --git a/modules/@angular/common/testing/facade b/modules/@angular/common/testing/facade deleted file mode 120000 index e084c803c6..0000000000 --- a/modules/@angular/common/testing/facade +++ /dev/null @@ -1 +0,0 @@ -../../facade/src \ No newline at end of file diff --git a/modules/@angular/compiler/src/assertions.ts b/modules/@angular/compiler/src/assertions.ts index 31d246e68b..a3a525e202 100644 --- a/modules/@angular/compiler/src/assertions.ts +++ b/modules/@angular/compiler/src/assertions.ts @@ -8,10 +8,9 @@ import {isDevMode} from '@angular/core'; -import {isBlank, isPresent} from '../src/facade/lang'; export function assertArrayOfStrings(identifier: string, value: any) { - if (!isDevMode() || isBlank(value)) { + if (!isDevMode() || value == null) { return; } if (!Array.isArray(value)) { @@ -33,9 +32,9 @@ const INTERPOLATION_BLACKLIST_REGEXPS = [ ]; export function assertInterpolationSymbols(identifier: string, value: any): void { - if (isPresent(value) && !(Array.isArray(value) && value.length == 2)) { + if (value != null && !(Array.isArray(value) && value.length == 2)) { throw new Error(`Expected '${identifier}' to be an array, [start, end].`); - } else if (isDevMode() && !isBlank(value)) { + } else if (isDevMode() && value != null) { const start = value[0] as string; const end = value[1] as string; // black list checking diff --git a/modules/@angular/compiler/src/compile_metadata.ts b/modules/@angular/compiler/src/compile_metadata.ts index aae128529a..f343b8ff6a 100644 --- a/modules/@angular/compiler/src/compile_metadata.ts +++ b/modules/@angular/compiler/src/compile_metadata.ts @@ -6,9 +6,8 @@ * found in the LICENSE file at https://angular.io/license */ -import {ChangeDetectionStrategy, ComponentFactory, RendererTypeV2, SchemaMetadata, Type, ViewEncapsulation, ɵLifecycleHooks, ɵreflector} from '@angular/core'; +import {ChangeDetectionStrategy, ComponentFactory, RendererTypeV2, SchemaMetadata, Type, ViewEncapsulation, ɵLifecycleHooks, ɵreflector, ɵstringify as stringify} from '@angular/core'; import {StaticSymbol} from './aot/static_symbol'; -import {isPresent, stringify} from './facade/lang'; import {CssSelector} from './selector'; import {splitAtColon} from './util'; @@ -179,12 +178,11 @@ export interface CompileFactoryMetadata extends CompileIdentifierMetadata { } export function tokenName(token: CompileTokenMetadata) { - return isPresent(token.value) ? _sanitizeIdentifier(token.value) : - identifierName(token.identifier); + return token.value != null ? _sanitizeIdentifier(token.value) : identifierName(token.identifier); } export function tokenReference(token: CompileTokenMetadata) { - if (isPresent(token.identifier)) { + if (token.identifier != null) { return token.identifier.reference; } else { return token.value; @@ -346,21 +344,21 @@ export class CompileDirectiveMetadata { const hostListeners: {[key: string]: string} = {}; const hostProperties: {[key: string]: string} = {}; const hostAttributes: {[key: string]: string} = {}; - if (isPresent(host)) { + if (host != null) { Object.keys(host).forEach(key => { const value = host[key]; const matches = key.match(HOST_REG_EXP); if (matches === null) { hostAttributes[key] = value; - } else if (isPresent(matches[1])) { + } else if (matches[1] != null) { hostProperties[matches[1]] = value; - } else if (isPresent(matches[2])) { + } else if (matches[2] != null) { hostListeners[matches[2]] = value; } }); } const inputsMap: {[key: string]: string} = {}; - if (isPresent(inputs)) { + if (inputs != null) { inputs.forEach((bindConfig: string) => { // canonical syntax: `dirProp: elProp` // if there is no `:`, use dirProp = elProp @@ -369,7 +367,7 @@ export class CompileDirectiveMetadata { }); } const outputsMap: {[key: string]: string} = {}; - if (isPresent(outputs)) { + if (outputs != null) { outputs.forEach((bindConfig: string) => { // canonical syntax: `dirProp: elProp` // if there is no `:`, use dirProp = elProp diff --git a/modules/@angular/compiler/src/compiler_util/expression_converter.ts b/modules/@angular/compiler/src/compiler_util/expression_converter.ts index 8dfa1a7f18..1d5ab7ff5d 100644 --- a/modules/@angular/compiler/src/compiler_util/expression_converter.ts +++ b/modules/@angular/compiler/src/compiler_util/expression_converter.ts @@ -8,7 +8,6 @@ import * as cdAst from '../expression_parser/ast'; -import {isBlank} from '../facade/lang'; import {Identifiers, createIdentifier} from '../identifiers'; import * as o from '../output/output_ast'; @@ -338,7 +337,7 @@ class _AstToIrVisitor implements cdAst.AstVisitor { result = varExpr.callFn(args); } } - if (isBlank(result)) { + if (result == null) { result = receiver.callMethod(ast.name, args); } return convertToStatementIfNeeded(mode, result); @@ -359,7 +358,7 @@ class _AstToIrVisitor implements cdAst.AstVisitor { if (receiver === this._implicitReceiver) { result = this._getLocal(ast.name); } - if (isBlank(result)) { + if (result == null) { result = receiver.prop(ast.name); } return convertToStatementIfNeeded(mode, result); @@ -607,4 +606,4 @@ class BuiltinFunctionCall extends cdAst.FunctionCall { constructor(span: cdAst.ParseSpan, public args: cdAst.AST[], public converter: BuiltinConverter) { super(span, null, args); } -} \ No newline at end of file +} diff --git a/modules/@angular/compiler/src/css_parser/css_lexer.ts b/modules/@angular/compiler/src/css_parser/css_lexer.ts index ee97f6e027..417c62dd0d 100644 --- a/modules/@angular/compiler/src/css_parser/css_lexer.ts +++ b/modules/@angular/compiler/src/css_parser/css_lexer.ts @@ -8,7 +8,6 @@ import * as chars from '../chars'; -import {isPresent} from '../facade/lang'; export enum CssTokenType { EOF, @@ -200,9 +199,9 @@ export class CssScanner { let next: CssToken; const output = this.scan(); - if (isPresent(output)) { + if (output != null) { // just incase the inner scan method returned an error - if (isPresent(output.error)) { + if (output.error != null) { this.setMode(mode); return output; } @@ -210,7 +209,7 @@ export class CssScanner { next = output.token; } - if (!isPresent(next)) { + if (next == null) { next = new CssToken(this.index, this.column, this.line, CssTokenType.EOF, 'end of file'); } @@ -227,11 +226,11 @@ export class CssScanner { this.setMode(mode); let error: Error = null; - if (!isMatchingType || (isPresent(value) && value != next.strValue)) { + if (!isMatchingType || (value != null && value != next.strValue)) { let errorMessage = CssTokenType[next.type] + ' does not match expected ' + CssTokenType[type] + ' value'; - if (isPresent(value)) { + if (value != null) { errorMessage += ' ("' + next.strValue + '" should match "' + value + '")'; } diff --git a/modules/@angular/compiler/src/css_parser/css_parser.ts b/modules/@angular/compiler/src/css_parser/css_parser.ts index b5d1856aaa..1932a08f77 100644 --- a/modules/@angular/compiler/src/css_parser/css_parser.ts +++ b/modules/@angular/compiler/src/css_parser/css_parser.ts @@ -7,7 +7,6 @@ */ import * as chars from '../chars'; -import {isPresent} from '../facade/lang'; import {ParseError, ParseLocation, ParseSourceFile, ParseSourceSpan} from '../parse_util'; import {BlockType, CssAst, CssAtRulePredicateAst, CssBlockAst, CssBlockDefinitionRuleAst, CssBlockRuleAst, CssDefinitionAst, CssInlineRuleAst, CssKeyframeDefinitionAst, CssKeyframeRuleAst, CssMediaQueryRuleAst, CssPseudoSelectorAst, CssRuleAst, CssSelectorAst, CssSelectorRuleAst, CssSimpleSelectorAst, CssStyleSheetAst, CssStyleValueAst, CssStylesBlockAst, CssUnknownRuleAst, CssUnknownTokenListAst, mergeTokens} from './css_ast'; @@ -127,7 +126,7 @@ export class CssParser { } /** @internal */ - _getSourceContent(): string { return isPresent(this._scanner) ? this._scanner.input : ''; } + _getSourceContent(): string { return this._scanner != null ? this._scanner.input : ''; } /** @internal */ _extractSourceContent(start: number, end: number): string { @@ -141,7 +140,7 @@ export class CssParser { startLoc = start.location.start; } else { let token = start; - if (!isPresent(token)) { + if (token == null) { // the data here is invalid, however, if and when this does // occur, any other errors associated with this will be collected token = this._lastToken; @@ -149,7 +148,7 @@ export class CssParser { startLoc = new ParseLocation(this._file, token.index, token.line, token.column); } - if (!isPresent(end)) { + if (end == null) { end = this._lastToken; } @@ -329,7 +328,7 @@ export class CssParser { let ruleAst: CssRuleAst; let span: ParseSourceSpan; const startSelector = selectors[0]; - if (isPresent(block)) { + if (block != null) { span = this._generateSourceSpan(startSelector, block); ruleAst = new CssSelectorRuleAst(span, selectors, block); } else { @@ -377,7 +376,7 @@ export class CssParser { const output = this._scanner.scan(); const token = output.token; const error = output.error; - if (isPresent(error)) { + if (error != null) { this._error(getRawMessage(error), token); } this._lastToken = token; @@ -392,7 +391,7 @@ export class CssParser { const output = this._scanner.consume(type, value); const token = output.token; const error = output.error; - if (isPresent(error)) { + if (error != null) { this._error(getRawMessage(error), token); } this._lastToken = token; @@ -601,7 +600,7 @@ export class CssParser { let index = lastOperatorToken.index; let line = lastOperatorToken.line; let column = lastOperatorToken.column; - if (isPresent(deepToken) && deepToken.strValue.toLowerCase() == 'deep' && + if (deepToken != null && deepToken.strValue.toLowerCase() == 'deep' && deepSlash.strValue == SLASH_CHARACTER) { token = new CssToken( lastOperatorToken.index, lastOperatorToken.column, lastOperatorToken.line, @@ -636,7 +635,7 @@ export class CssParser { // so long as there is an operator then we can have an // ending value that is beyond the selector value ... // otherwise it's just a bunch of trailing whitespace - if (isPresent(operator)) { + if (operator != null) { end = operator.index; } } @@ -664,7 +663,7 @@ export class CssParser { startTokenOrAst = startTokenOrAst || pseudoSelectors[0]; endTokenOrAst = pseudoSelectors[pseudoSelectors.length - 1]; } - if (isPresent(operator)) { + if (operator != null) { startTokenOrAst = startTokenOrAst || operator; endTokenOrAst = operator; } @@ -702,7 +701,7 @@ export class CssParser { let previous: CssToken; while (!characterContainsDelimiter(this._scanner.peek, delimiters)) { let token: CssToken; - if (isPresent(previous) && previous.type == CssTokenType.Identifier && + if (previous != null && previous.type == CssTokenType.Identifier && this._scanner.peek == chars.$LPAREN) { token = this._consume(CssTokenType.Character, '('); tokens.push(token); @@ -753,7 +752,7 @@ export class CssParser { _collectUntilDelim(delimiters: number, assertType: CssTokenType = null): CssToken[] { const tokens: CssToken[] = []; while (!characterContainsDelimiter(this._scanner.peek, delimiters)) { - const val = isPresent(assertType) ? this._consume(assertType) : this._scan(); + const val = assertType != null ? this._consume(assertType) : this._scan(); tokens.push(val); } return tokens; diff --git a/modules/@angular/compiler/src/directive_normalizer.ts b/modules/@angular/compiler/src/directive_normalizer.ts index 388522e3b9..1ae15e24e9 100644 --- a/modules/@angular/compiler/src/directive_normalizer.ts +++ b/modules/@angular/compiler/src/directive_normalizer.ts @@ -6,11 +6,9 @@ * found in the LICENSE file at https://angular.io/license */ -import {ViewEncapsulation} from '@angular/core'; - +import {ViewEncapsulation, ɵstringify as stringify} from '@angular/core'; import {CompileAnimationEntryMetadata, CompileDirectiveMetadata, CompileStylesheetMetadata, CompileTemplateMetadata} from './compile_metadata'; import {CompilerConfig} from './config'; -import {stringify} from './facade/lang'; import {CompilerInjectable} from './injectable'; import * as html from './ml_parser/ast'; import {HtmlParser} from './ml_parser/html_parser'; diff --git a/modules/@angular/compiler/src/directive_resolver.ts b/modules/@angular/compiler/src/directive_resolver.ts index 2df95423ac..425d02a535 100644 --- a/modules/@angular/compiler/src/directive_resolver.ts +++ b/modules/@angular/compiler/src/directive_resolver.ts @@ -6,9 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -import {Component, Directive, HostBinding, HostListener, Input, Output, Query, Type, resolveForwardRef, ɵReflectorReader, ɵmerge as merge, ɵreflector} from '@angular/core'; - -import {stringify} from './facade/lang'; +import {Component, Directive, HostBinding, HostListener, Input, Output, Query, Type, resolveForwardRef, ɵReflectorReader, ɵmerge as merge, ɵreflector, ɵstringify as stringify} from '@angular/core'; import {CompilerInjectable} from './injectable'; import {splitAtColon} from './util'; diff --git a/modules/@angular/compiler/src/expression_parser/ast.ts b/modules/@angular/compiler/src/expression_parser/ast.ts index 23437ca195..8c5724ca11 100644 --- a/modules/@angular/compiler/src/expression_parser/ast.ts +++ b/modules/@angular/compiler/src/expression_parser/ast.ts @@ -7,7 +7,6 @@ */ -import {isBlank} from '../facade/lang'; export class ParserError { public message: string; @@ -196,7 +195,7 @@ export class ASTWithSource extends AST { constructor( public ast: AST, public source: string, public location: string, public errors: ParserError[]) { - super(new ParseSpan(0, isBlank(source) ? 0 : source.length)); + super(new ParseSpan(0, source == null ? 0 : source.length)); } visit(visitor: AstVisitor, context: any = null): any { return this.ast.visit(visitor, context); } toString(): string { return `${this.source} in ${this.location}`; } diff --git a/modules/@angular/compiler/src/expression_parser/lexer.ts b/modules/@angular/compiler/src/expression_parser/lexer.ts index 8f3cd60fc9..d097d9b5ce 100644 --- a/modules/@angular/compiler/src/expression_parser/lexer.ts +++ b/modules/@angular/compiler/src/expression_parser/lexer.ts @@ -7,7 +7,6 @@ */ import * as chars from '../chars'; -import {NumberWrapper} from '../facade/lang'; import {CompilerInjectable} from '../injectable'; export enum TokenType { @@ -276,7 +275,7 @@ class _Scanner { this.advance(); } const str: string = this.input.substring(start, this.index); - const value: number = simple ? NumberWrapper.parseIntAutoRadix(str) : parseFloat(str); + const value: number = simple ? parseIntAutoRadix(str) : parseFloat(str); return newNumberToken(start, value); } @@ -383,3 +382,11 @@ function unescape(code: number): number { return code; } } + +function parseIntAutoRadix(text: string): number { + const result: number = parseInt(text); + if (isNaN(result)) { + throw new Error('Invalid integer literal when parsing ' + text); + } + return result; +} diff --git a/modules/@angular/compiler/src/expression_parser/parser.ts b/modules/@angular/compiler/src/expression_parser/parser.ts index f90ada465d..d2e5ec0f60 100644 --- a/modules/@angular/compiler/src/expression_parser/parser.ts +++ b/modules/@angular/compiler/src/expression_parser/parser.ts @@ -7,10 +7,9 @@ */ import * as chars from '../chars'; -import {escapeRegExp, isBlank, isPresent} from '../facade/lang'; import {CompilerInjectable} from '../injectable'; import {DEFAULT_INTERPOLATION_CONFIG, InterpolationConfig} from '../ml_parser/interpolation_config'; - +import {escapeRegExp} from '../util'; import {AST, ASTWithSource, AstVisitor, Binary, BindingPipe, Chain, Conditional, EmptyExpr, FunctionCall, ImplicitReceiver, Interpolation, KeyedRead, KeyedWrite, LiteralArray, LiteralMap, LiteralPrimitive, MethodCall, ParseSpan, ParserError, PrefixNot, PropertyRead, PropertyWrite, Quote, SafeMethodCall, SafePropertyRead, TemplateBinding} from './ast'; import {EOF, Lexer, Token, TokenType, isIdentifier, isQuote} from './lexer'; @@ -78,7 +77,7 @@ export class Parser { // our lexer or parser for that, so we check for that ahead of time. const quote = this._parseQuote(input, location); - if (isPresent(quote)) { + if (quote != null) { return quote; } @@ -92,7 +91,7 @@ export class Parser { } private _parseQuote(input: string, location: any): AST { - if (isBlank(input)) return null; + if (input == null) return null; const prefixSeparatorIndex = input.indexOf(':'); if (prefixSeparatorIndex == -1) return null; const prefix = input.substring(0, prefixSeparatorIndex).trim(); @@ -137,7 +136,7 @@ export class Parser { return new ASTWithSource( new Interpolation( - new ParseSpan(0, isBlank(input) ? 0 : input.length), split.strings, expressions), + new ParseSpan(0, input == null ? 0 : input.length), split.strings, expressions), input, location, this.errors); } @@ -178,13 +177,13 @@ export class Parser { wrapLiteralPrimitive(input: string, location: any): ASTWithSource { return new ASTWithSource( - new LiteralPrimitive(new ParseSpan(0, isBlank(input) ? 0 : input.length), input), input, + new LiteralPrimitive(new ParseSpan(0, input == null ? 0 : input.length), input), input, location, this.errors); } private _stripComments(input: string): string { const i = this._commentStart(input); - return isPresent(i) ? input.substring(0, i).trim() : input; + return i != null ? input.substring(0, i).trim() : input; } private _commentStart(input: string): number { @@ -193,11 +192,11 @@ export class Parser { const char = input.charCodeAt(i); const nextChar = input.charCodeAt(i + 1); - if (char === chars.$SLASH && nextChar == chars.$SLASH && isBlank(outerQuote)) return i; + if (char === chars.$SLASH && nextChar == chars.$SLASH && outerQuote == null) return i; if (outerQuote === char) { outerQuote = null; - } else if (isBlank(outerQuote) && isQuote(char)) { + } else if (outerQuote == null && isQuote(char)) { outerQuote = char; } } @@ -728,7 +727,7 @@ export class _ParseAST { } private locationText(index: number = null) { - if (isBlank(index)) index = this.index; + if (index == null) index = this.index; return (index < this.tokens.length) ? `at column ${this.tokens[index].index + 1} in` : `at the end of the expression`; } diff --git a/modules/@angular/compiler/src/facade b/modules/@angular/compiler/src/facade deleted file mode 120000 index e084c803c6..0000000000 --- a/modules/@angular/compiler/src/facade +++ /dev/null @@ -1 +0,0 @@ -../../facade/src \ No newline at end of file diff --git a/modules/@angular/compiler/src/jit/compiler.ts b/modules/@angular/compiler/src/jit/compiler.ts index 3481d2ae07..5c6e558a2f 100644 --- a/modules/@angular/compiler/src/jit/compiler.ts +++ b/modules/@angular/compiler/src/jit/compiler.ts @@ -6,11 +6,10 @@ * found in the LICENSE file at https://angular.io/license */ -import {Compiler, ComponentFactory, Inject, Injector, ModuleWithComponentFactories, NgModuleFactory, Type, ɵgetComponentViewDefinitionFactory as getComponentViewDefinitionFactory} from '@angular/core'; +import {Compiler, ComponentFactory, Inject, Injector, ModuleWithComponentFactories, NgModuleFactory, Type, ɵgetComponentViewDefinitionFactory as getComponentViewDefinitionFactory, ɵstringify as stringify} from '@angular/core'; import {CompileDirectiveMetadata, CompileIdentifierMetadata, CompileNgModuleMetadata, ProviderMeta, ProxyClass, createHostComponentMeta, identifierName} from '../compile_metadata'; import {CompilerConfig} from '../config'; -import {stringify} from '../facade/lang'; import {CompilerInjectable} from '../injectable'; import {CompileMetadataResolver} from '../metadata_resolver'; import {NgModuleCompiler} from '../ng_module_compiler'; diff --git a/modules/@angular/compiler/src/metadata_resolver.ts b/modules/@angular/compiler/src/metadata_resolver.ts index 32e3a6f88a..407391c526 100644 --- a/modules/@angular/compiler/src/metadata_resolver.ts +++ b/modules/@angular/compiler/src/metadata_resolver.ts @@ -6,8 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -import {Attribute, ChangeDetectionStrategy, Component, ComponentFactory, Directive, Host, Inject, Injectable, InjectionToken, ModuleWithProviders, Optional, Provider, Query, RendererTypeV2, SchemaMetadata, Self, SkipSelf, Type, resolveForwardRef, ɵERROR_COMPONENT_TYPE, ɵLIFECYCLE_HOOKS_VALUES, ɵReflectorReader, ɵccf as createComponentFactory, ɵreflector} from '@angular/core'; - +import {Attribute, ChangeDetectionStrategy, Component, ComponentFactory, Directive, Host, Inject, Injectable, InjectionToken, ModuleWithProviders, Optional, Provider, Query, RendererTypeV2, SchemaMetadata, Self, SkipSelf, Type, resolveForwardRef, ɵERROR_COMPONENT_TYPE, ɵLIFECYCLE_HOOKS_VALUES, ɵReflectorReader, ɵccf as createComponentFactory, ɵreflector, ɵstringify as stringify} from '@angular/core'; import {StaticSymbol, StaticSymbolCache} from './aot/static_symbol'; import {ngfactoryFilePath} from './aot/util'; import {assertArrayOfStrings, assertInterpolationSymbols} from './assertions'; @@ -15,7 +14,6 @@ import * as cpl from './compile_metadata'; import {CompilerConfig} from './config'; import {DirectiveNormalizer} from './directive_normalizer'; import {DirectiveResolver} from './directive_resolver'; -import {stringify} from './facade/lang'; import {Identifiers, resolveIdentifier} from './identifiers'; import {CompilerInjectable} from './injectable'; import {hasLifecycleHook} from './lifecycle_reflector'; diff --git a/modules/@angular/compiler/src/ml_parser/parser.ts b/modules/@angular/compiler/src/ml_parser/parser.ts index 2c1473daff..e59574d221 100644 --- a/modules/@angular/compiler/src/ml_parser/parser.ts +++ b/modules/@angular/compiler/src/ml_parser/parser.ts @@ -6,7 +6,6 @@ * found in the LICENSE file at https://angular.io/license */ -import {isBlank, isPresent} from '../facade/lang'; import {ParseError, ParseSourceSpan} from '../parse_util'; import * as html from './ast'; @@ -109,7 +108,7 @@ class _TreeBuilder { private _consumeComment(token: lex.Token) { const text = this._advanceIf(lex.TokenType.RAW_TEXT); this._advanceIf(lex.TokenType.COMMENT_END); - const value = isPresent(text) ? text.parts[0].trim() : null; + const value = text != null ? text.parts[0].trim() : null; this._addToParent(new html.Comment(value, token.sourceSpan)); } @@ -217,7 +216,7 @@ class _TreeBuilder { let text = token.parts[0]; if (text.length > 0 && text[0] == '\n') { const parent = this._getParentElement(); - if (isPresent(parent) && parent.children.length == 0 && + if (parent != null && parent.children.length == 0 && this.getTagDefinition(parent.name).ignoreFirstLf) { text = text.substring(1); } @@ -365,7 +364,7 @@ class _TreeBuilder { private _addToParent(node: html.Node) { const parent = this._getParentElement(); - if (isPresent(parent)) { + if (parent != null) { parent.children.push(node); } else { this._rootNodes.push(node); @@ -399,9 +398,9 @@ class _TreeBuilder { private _getElementFullName(prefix: string, localName: string, parentElement: html.Element): string { - if (isBlank(prefix)) { + if (prefix == null) { prefix = this.getTagDefinition(localName).implicitNamespacePrefix; - if (isBlank(prefix) && isPresent(parentElement)) { + if (prefix == null && parentElement != null) { prefix = getNsPrefix(parentElement.name); } } diff --git a/modules/@angular/compiler/src/ng_module_compiler.ts b/modules/@angular/compiler/src/ng_module_compiler.ts index 1a29d9fe3b..ed5b1f7e2f 100644 --- a/modules/@angular/compiler/src/ng_module_compiler.ts +++ b/modules/@angular/compiler/src/ng_module_compiler.ts @@ -9,7 +9,6 @@ import {ɵLifecycleHooks} from '@angular/core'; import {CompileDiDependencyMetadata, CompileIdentifierMetadata, CompileNgModuleMetadata, CompileProviderMetadata, CompileTokenMetadata, identifierModuleUrl, identifierName, tokenName, tokenReference} from './compile_metadata'; -import {isPresent} from './facade/lang'; import {Identifiers, createIdentifier, resolveIdentifier} from './identifiers'; import {CompilerInjectable} from './injectable'; import {ClassBuilder, createClassStmt} from './output/class_builder'; @@ -39,7 +38,7 @@ export class NgModuleCompiler { compile(ngModuleMeta: CompileNgModuleMetadata, extraProviders: CompileProviderMetadata[]): NgModuleCompileResult { const moduleUrl = identifierModuleUrl(ngModuleMeta.type); - const sourceFileName = isPresent(moduleUrl) ? + const sourceFileName = moduleUrl != null ? `in NgModule ${identifierName(ngModuleMeta.type)} in ${moduleUrl}` : `in NgModule ${identifierName(ngModuleMeta.type)}`; const sourceFile = new ParseSourceFile('', sourceFileName); @@ -161,13 +160,13 @@ class _InjectorBuilder implements ClassBuilder { private _getProviderValue(provider: CompileProviderMetadata): o.Expression { let result: o.Expression; - if (isPresent(provider.useExisting)) { + if (provider.useExisting != null) { result = this._getDependency({token: provider.useExisting}); - } else if (isPresent(provider.useFactory)) { + } else if (provider.useFactory != null) { const deps = provider.deps || provider.useFactory.diDeps; const depsExpr = deps.map((dep) => this._getDependency(dep)); result = o.importExpr(provider.useFactory).callFn(depsExpr); - } else if (isPresent(provider.useClass)) { + } else if (provider.useClass != null) { const deps = provider.deps || provider.useClass.diDeps; const depsExpr = deps.map((dep) => this._getDependency(dep)); result = @@ -239,7 +238,7 @@ class _InjectorBuilder implements ClassBuilder { } function createDiTokenExpression(token: CompileTokenMetadata): o.Expression { - if (isPresent(token.value)) { + if (token.value != null) { return o.literal(token.value); } else { return o.importExpr(token.identifier); diff --git a/modules/@angular/compiler/src/ng_module_resolver.ts b/modules/@angular/compiler/src/ng_module_resolver.ts index 3424a86ab4..96ed919126 100644 --- a/modules/@angular/compiler/src/ng_module_resolver.ts +++ b/modules/@angular/compiler/src/ng_module_resolver.ts @@ -6,9 +6,8 @@ * found in the LICENSE file at https://angular.io/license */ -import {NgModule, Type, ɵReflectorReader, ɵreflector} from '@angular/core'; +import {NgModule, Type, ɵReflectorReader, ɵreflector, ɵstringify as stringify} from '@angular/core'; import {findLast} from './directive_resolver'; -import {stringify} from './facade/lang'; import {CompilerInjectable} from './injectable'; function _isNgModuleMetadata(obj: any): obj is NgModule { diff --git a/modules/@angular/compiler/src/output/abstract_emitter.ts b/modules/@angular/compiler/src/output/abstract_emitter.ts index e4000da68e..0d574221ca 100644 --- a/modules/@angular/compiler/src/output/abstract_emitter.ts +++ b/modules/@angular/compiler/src/output/abstract_emitter.ts @@ -6,7 +6,6 @@ * found in the LICENSE file at https://angular.io/license */ -import {isBlank, isPresent} from '../facade/lang'; import {ParseSourceSpan} from '../parse_util'; import * as o from './output_ast'; @@ -164,7 +163,7 @@ export abstract class AbstractEmitterVisitor implements o.StatementVisitor, o.Ex ctx.print(stmt, `if (`); stmt.condition.visitExpression(this, ctx); ctx.print(stmt, `) {`); - const hasElseCase = isPresent(stmt.falseCase) && stmt.falseCase.length > 0; + const hasElseCase = stmt.falseCase != null && stmt.falseCase.length > 0; if (stmt.trueCase.length <= 1 && !hasElseCase) { ctx.print(stmt, ` `); this.visitAllStatements(stmt.trueCase, ctx); @@ -244,9 +243,9 @@ export abstract class AbstractEmitterVisitor implements o.StatementVisitor, o.Ex visitInvokeMethodExpr(expr: o.InvokeMethodExpr, ctx: EmitterVisitorContext): any { expr.receiver.visitExpression(this, ctx); let name = expr.name; - if (isPresent(expr.builtin)) { + if (expr.builtin != null) { name = this.getBuiltinMethodName(expr.builtin); - if (isBlank(name)) { + if (name == null) { // some builtins just mean to skip the call. return null; } @@ -268,7 +267,7 @@ export abstract class AbstractEmitterVisitor implements o.StatementVisitor, o.Ex } visitReadVarExpr(ast: o.ReadVarExpr, ctx: EmitterVisitorContext): any { let varName = ast.name; - if (isPresent(ast.builtin)) { + if (ast.builtin != null) { switch (ast.builtin) { case o.BuiltinVar.Super: varName = 'super'; @@ -450,7 +449,7 @@ export abstract class AbstractEmitterVisitor implements o.StatementVisitor, o.Ex export function escapeIdentifier( input: string, escapeDollar: boolean, alwaysQuote: boolean = true): any { - if (isBlank(input)) { + if (input == null) { return null; } const body = input.replace(_SINGLE_QUOTE_ESCAPE_STRING_RE, (...match: string[]) => { diff --git a/modules/@angular/compiler/src/output/abstract_js_emitter.ts b/modules/@angular/compiler/src/output/abstract_js_emitter.ts index cf3febd296..07c9db20c4 100644 --- a/modules/@angular/compiler/src/output/abstract_js_emitter.ts +++ b/modules/@angular/compiler/src/output/abstract_js_emitter.ts @@ -6,7 +6,6 @@ * found in the LICENSE file at https://angular.io/license */ -import {isPresent} from '../facade/lang'; import {AbstractEmitterVisitor, CATCH_ERROR_VAR, CATCH_STACK_VAR, EmitterVisitorContext} from './abstract_emitter'; import * as o from './output_ast'; @@ -17,7 +16,7 @@ export abstract class AbstractJsEmitterVisitor extends AbstractEmitterVisitor { ctx.pushClass(stmt); this._visitClassConstructor(stmt, ctx); - if (isPresent(stmt.parent)) { + if (stmt.parent != null) { ctx.print(stmt, `${stmt.name}.prototype = Object.create(`); stmt.parent.visitExpression(this, ctx); ctx.println(stmt, `.prototype);`); @@ -30,12 +29,12 @@ export abstract class AbstractJsEmitterVisitor extends AbstractEmitterVisitor { private _visitClassConstructor(stmt: o.ClassStmt, ctx: EmitterVisitorContext) { ctx.print(stmt, `function ${stmt.name}(`); - if (isPresent(stmt.constructorMethod)) { + if (stmt.constructorMethod != null) { this._visitParams(stmt.constructorMethod.params, ctx); } ctx.println(stmt, `) {`); ctx.incIndent(); - if (isPresent(stmt.constructorMethod)) { + if (stmt.constructorMethod != null) { if (stmt.constructorMethod.body.length > 0) { ctx.println(stmt, `var self = this;`); this.visitAllStatements(stmt.constructorMethod.body, ctx); diff --git a/modules/@angular/compiler/src/output/js_emitter.ts b/modules/@angular/compiler/src/output/js_emitter.ts index fc3b5d64d6..2b331b2dfc 100644 --- a/modules/@angular/compiler/src/output/js_emitter.ts +++ b/modules/@angular/compiler/src/output/js_emitter.ts @@ -9,7 +9,6 @@ import {StaticSymbol} from '../aot/static_symbol'; import {CompileIdentifierMetadata} from '../compile_metadata'; -import {isBlank} from '../facade/lang'; import {EmitterVisitorContext, OutputEmitter} from './abstract_emitter'; import {AbstractJsEmitterVisitor} from './abstract_js_emitter'; @@ -61,7 +60,7 @@ class JsEmitterVisitor extends AbstractJsEmitterVisitor { const {name, filePath} = this._resolveStaticSymbol(ast.value); if (filePath != this._genFilePath) { let prefix = this.importsWithPrefixes.get(filePath); - if (isBlank(prefix)) { + if (prefix == null) { prefix = `import${this.importsWithPrefixes.size}`; this.importsWithPrefixes.set(filePath, prefix); } diff --git a/modules/@angular/compiler/src/output/output_ast.ts b/modules/@angular/compiler/src/output/output_ast.ts index 30b7134937..95a3108d4c 100644 --- a/modules/@angular/compiler/src/output/output_ast.ts +++ b/modules/@angular/compiler/src/output/output_ast.ts @@ -8,7 +8,6 @@ import {CompileIdentifierMetadata} from '../compile_metadata'; -import {isPresent} from '../facade/lang'; import {ParseSourceSpan} from '../parse_util'; //// Types @@ -954,12 +953,12 @@ export function importExpr( export function importType( id: CompileIdentifierMetadata, typeParams: Type[] = null, typeModifiers: TypeModifier[] = null): ExpressionType { - return isPresent(id) ? expressionType(importExpr(id, typeParams), typeModifiers) : null; + return id != null ? expressionType(importExpr(id, typeParams), typeModifiers) : null; } export function expressionType( expr: Expression, typeModifiers: TypeModifier[] = null): ExpressionType { - return isPresent(expr) ? new ExpressionType(expr, typeModifiers) : null; + return expr != null ? new ExpressionType(expr, typeModifiers) : null; } export function literalArr( diff --git a/modules/@angular/compiler/src/output/output_interpreter.ts b/modules/@angular/compiler/src/output/output_interpreter.ts index eddc654119..a30d4b0515 100644 --- a/modules/@angular/compiler/src/output/output_interpreter.ts +++ b/modules/@angular/compiler/src/output/output_interpreter.ts @@ -7,7 +7,6 @@ */ -import {isPresent} from '../facade/lang'; import * as o from './output_ast'; import {debugOutputAstAsTypeScript} from './ts_emitter'; @@ -18,7 +17,7 @@ export function interpretStatements(statements: o.Statement[], resultVars: strin const ctx = new _ExecutionContext(null, null, null, new Map()); const visitor = new StatementInterpreter(); const result = visitor.visitAllStatements(stmtsWithReturn, ctx); - return isPresent(result) ? result.value : null; + return result != null ? result.value : null; } function _executeFunctionStatements( @@ -107,7 +106,7 @@ class StatementInterpreter implements o.StatementVisitor, o.ExpressionVisitor { } visitReadVarExpr(ast: o.ReadVarExpr, ctx: _ExecutionContext): any { let varName = ast.name; - if (isPresent(ast.builtin)) { + if (ast.builtin != null) { switch (ast.builtin) { case o.BuiltinVar.Super: return ctx.instance.__proto__; @@ -150,7 +149,7 @@ class StatementInterpreter implements o.StatementVisitor, o.ExpressionVisitor { const receiver = expr.receiver.visitExpression(this, ctx); const args = this.visitAllExpressions(expr.args, ctx); let result: any; - if (isPresent(expr.builtin)) { + if (expr.builtin != null) { switch (expr.builtin) { case o.BuiltinMethod.ConcatArray: result = receiver.concat(...args); @@ -195,7 +194,7 @@ class StatementInterpreter implements o.StatementVisitor, o.ExpressionVisitor { const condition = stmt.condition.visitExpression(this, ctx); if (condition) { return this.visitAllStatements(stmt.trueCase, ctx); - } else if (isPresent(stmt.falseCase)) { + } else if (stmt.falseCase != null) { return this.visitAllStatements(stmt.falseCase, ctx); } return null; @@ -226,7 +225,7 @@ class StatementInterpreter implements o.StatementVisitor, o.ExpressionVisitor { visitConditionalExpr(ast: o.ConditionalExpr, ctx: _ExecutionContext): any { if (ast.condition.visitExpression(this, ctx)) { return ast.trueCase.visitExpression(this, ctx); - } else if (isPresent(ast.falseCase)) { + } else if (ast.falseCase != null) { return ast.falseCase.visitExpression(this, ctx); } return null; diff --git a/modules/@angular/compiler/src/output/ts_emitter.ts b/modules/@angular/compiler/src/output/ts_emitter.ts index 7846655ce7..2806e076d4 100644 --- a/modules/@angular/compiler/src/output/ts_emitter.ts +++ b/modules/@angular/compiler/src/output/ts_emitter.ts @@ -9,7 +9,6 @@ import {StaticSymbol} from '../aot/static_symbol'; import {CompileIdentifierMetadata} from '../compile_metadata'; -import {isBlank, isPresent} from '../facade/lang'; import {AbstractEmitterVisitor, CATCH_ERROR_VAR, CATCH_STACK_VAR, EmitterVisitorContext, OutputEmitter} from './abstract_emitter'; import * as o from './output_ast'; @@ -91,7 +90,7 @@ class _TsEmitterVisitor extends AbstractEmitterVisitor implements o.TypeVisitor reexports = new Map(); visitType(t: o.Type, ctx: EmitterVisitorContext, defaultType: string = 'any') { - if (isPresent(t)) { + if (t != null) { this.typeExpression++; t.visitType(this, ctx); this.typeExpression--; @@ -102,7 +101,7 @@ class _TsEmitterVisitor extends AbstractEmitterVisitor implements o.TypeVisitor visitLiteralExpr(ast: o.LiteralExpr, ctx: EmitterVisitorContext): any { const value = ast.value; - if (isBlank(value) && ast.type != o.INFERRED_TYPE) { + if (value == null && ast.type != o.INFERRED_TYPE) { ctx.print(ast, `(${value} as any)`); return null; } @@ -186,7 +185,7 @@ class _TsEmitterVisitor extends AbstractEmitterVisitor implements o.TypeVisitor ctx.print(stmt, `export `); } ctx.print(stmt, `class ${stmt.name}`); - if (isPresent(stmt.parent)) { + if (stmt.parent != null) { ctx.print(stmt, ` extends `); this.typeExpression++; stmt.parent.visitExpression(this, ctx); @@ -195,7 +194,7 @@ class _TsEmitterVisitor extends AbstractEmitterVisitor implements o.TypeVisitor ctx.println(stmt, ` {`); ctx.incIndent(); stmt.fields.forEach((field) => this._visitClassField(field, ctx)); - if (isPresent(stmt.constructorMethod)) { + if (stmt.constructorMethod != null) { this._visitClassConstructor(stmt, ctx); } stmt.getters.forEach((getter) => this._visitClassGetter(getter, ctx)); @@ -391,7 +390,7 @@ class _TsEmitterVisitor extends AbstractEmitterVisitor implements o.TypeVisitor const {name, filePath, members, arity} = this._resolveStaticSymbol(value); if (filePath != this._genFilePath) { let prefix = this.importsWithPrefixes.get(filePath); - if (isBlank(prefix)) { + if (prefix == null) { prefix = `import${this.importsWithPrefixes.size}`; this.importsWithPrefixes.set(filePath, prefix); } diff --git a/modules/@angular/compiler/src/parse_util.ts b/modules/@angular/compiler/src/parse_util.ts index 4e2ba1dc27..1f2eb2b8a3 100644 --- a/modules/@angular/compiler/src/parse_util.ts +++ b/modules/@angular/compiler/src/parse_util.ts @@ -6,7 +6,6 @@ * found in the LICENSE file at https://angular.io/license */ import * as chars from './chars'; -import {isPresent} from './facade/lang'; export class ParseLocation { constructor( @@ -14,7 +13,7 @@ export class ParseLocation { public col: number) {} toString(): string { - return isPresent(this.offset) ? `${this.file.url}@${this.line}:${this.col}` : this.file.url; + return this.offset != null ? `${this.file.url}@${this.line}:${this.col}` : this.file.url; } moveBy(delta: number): ParseLocation { @@ -55,7 +54,7 @@ export class ParseLocation { const content = this.file.content; let startOffset = this.offset; - if (isPresent(startOffset)) { + if (startOffset != null) { if (startOffset > content.length - 1) { startOffset = content.length - 1; } diff --git a/modules/@angular/compiler/src/pipe_resolver.ts b/modules/@angular/compiler/src/pipe_resolver.ts index bb2f83d5d1..db56b62af2 100644 --- a/modules/@angular/compiler/src/pipe_resolver.ts +++ b/modules/@angular/compiler/src/pipe_resolver.ts @@ -6,9 +6,8 @@ * found in the LICENSE file at https://angular.io/license */ -import {Pipe, Type, resolveForwardRef, ɵReflectorReader, ɵreflector} from '@angular/core'; +import {Pipe, Type, resolveForwardRef, ɵReflectorReader, ɵreflector, ɵstringify as stringify} from '@angular/core'; import {findLast} from './directive_resolver'; -import {stringify} from './facade/lang'; import {CompilerInjectable} from './injectable'; function _isPipeMetadata(type: any): boolean { diff --git a/modules/@angular/compiler/src/provider_analyzer.ts b/modules/@angular/compiler/src/provider_analyzer.ts index b58f2c9112..f1772c821a 100644 --- a/modules/@angular/compiler/src/provider_analyzer.ts +++ b/modules/@angular/compiler/src/provider_analyzer.ts @@ -8,7 +8,6 @@ import {CompileDiDependencyMetadata, CompileDirectiveMetadata, CompileDirectiveSummary, CompileNgModuleMetadata, CompileProviderMetadata, CompileQueryMetadata, CompileTokenMetadata, CompileTypeMetadata, tokenName, tokenReference} from './compile_metadata'; -import {isBlank, isPresent} from './facade/lang'; import {Identifiers, createIdentifierToken, resolveIdentifier} from './identifiers'; import {ParseError, ParseSourceSpan} from './parse_util'; import {AttrAst, DirectiveAst, ProviderAst, ProviderAstType, QueryMatch, ReferenceAst} from './template_parser/template_ast'; @@ -37,7 +36,7 @@ export class ProviderViewContext { this.viewQueries = _getViewQueries(component); this.viewProviders = new Map(); component.viewProviders.forEach((provider) => { - if (isBlank(this.viewProviders.get(tokenReference(provider.token)))) { + if (this.viewProviders.get(tokenReference(provider.token)) == null) { this.viewProviders.set(tokenReference(provider.token), true); } }); @@ -171,7 +170,7 @@ export class ProviderElementContext { if (transformedProviderAst) { return transformedProviderAst; } - if (isPresent(this._seenProviders.get(tokenReference(token)))) { + if (this._seenProviders.get(tokenReference(token)) != null) { this.viewContext.errors.push(new ProviderError( `Cannot instantiate cyclic dependency! ${tokenName(token)}`, this._sourceSpan)); return null; @@ -181,10 +180,10 @@ export class ProviderElementContext { let transformedUseValue = provider.useValue; let transformedUseExisting = provider.useExisting; let transformedDeps: CompileDiDependencyMetadata[]; - if (isPresent(provider.useExisting)) { + if (provider.useExisting != null) { const existingDiDep = this._getDependency( resolvedProvider.providerType, {token: provider.useExisting}, eager); - if (isPresent(existingDiDep.token)) { + if (existingDiDep.token != null) { transformedUseExisting = existingDiDep.token; } else { transformedUseExisting = null; @@ -219,7 +218,7 @@ export class ProviderElementContext { return {isValue: true, value: attrValue == null ? null : attrValue}; } - if (isPresent(dep.token)) { + if (dep.token != null) { // access builtints if ((requestingProviderType === ProviderAstType.Directive || requestingProviderType === ProviderAstType.Component)) { @@ -238,7 +237,7 @@ export class ProviderElementContext { return dep; } // access providers - if (isPresent(this._getOrCreateLocalProvider(requestingProviderType, dep.token, eager))) { + if (this._getOrCreateLocalProvider(requestingProviderType, dep.token, eager) != null) { return dep; } } @@ -272,7 +271,7 @@ export class ProviderElementContext { if (!result) { if (!dep.isHost || this.viewContext.component.isHost || this.viewContext.component.type.reference === tokenReference(dep.token) || - isPresent(this.viewContext.viewProviders.get(tokenReference(dep.token)))) { + this.viewContext.viewProviders.get(tokenReference(dep.token)) != null) { result = dep; } else { result = dep.isOptional ? result = {isValue: true, value: null} : null; @@ -329,7 +328,7 @@ export class NgModuleProviderAnalyzer { if (transformedProviderAst) { return transformedProviderAst; } - if (isPresent(this._seenProviders.get(tokenReference(token)))) { + if (this._seenProviders.get(tokenReference(token)) != null) { this._errors.push(new ProviderError( `Cannot instantiate cyclic dependency! ${tokenName(token)}`, resolvedProvider.sourceSpan)); @@ -340,10 +339,10 @@ export class NgModuleProviderAnalyzer { let transformedUseValue = provider.useValue; let transformedUseExisting = provider.useExisting; let transformedDeps: CompileDiDependencyMetadata[]; - if (isPresent(provider.useExisting)) { + if (provider.useExisting != null) { const existingDiDep = this._getDependency({token: provider.useExisting}, eager, resolvedProvider.sourceSpan); - if (isPresent(existingDiDep.token)) { + if (existingDiDep.token != null) { transformedUseExisting = existingDiDep.token; } else { transformedUseExisting = null; @@ -374,13 +373,13 @@ export class NgModuleProviderAnalyzer { dep: CompileDiDependencyMetadata, eager: boolean = null, requestorSourceSpan: ParseSourceSpan): CompileDiDependencyMetadata { let foundLocal = false; - if (!dep.isSkipSelf && isPresent(dep.token)) { + if (!dep.isSkipSelf && dep.token != null) { // access the injector if (tokenReference(dep.token) === resolveIdentifier(Identifiers.Injector) || tokenReference(dep.token) === resolveIdentifier(Identifiers.ComponentFactoryResolver)) { foundLocal = true; // access providers - } else if (isPresent(this._getOrCreateLocalProvider(dep.token, eager))) { + } else if (this._getOrCreateLocalProvider(dep.token, eager) != null) { foundLocal = true; } } @@ -453,7 +452,7 @@ function _resolveProviders( targetProvidersByToken: Map) { providers.forEach((provider) => { let resolvedProvider = targetProvidersByToken.get(tokenReference(provider.token)); - if (isPresent(resolvedProvider) && !!resolvedProvider.multiProvider !== !!provider.multi) { + if (resolvedProvider != null && !!resolvedProvider.multiProvider !== !!provider.multi) { targetErrors.push(new ProviderError( `Mixing multi and non multi provider is not possible for token ${tokenName(resolvedProvider.token)}`, sourceSpan)); diff --git a/modules/@angular/compiler/src/template_parser/template_parser.ts b/modules/@angular/compiler/src/template_parser/template_parser.ts index 6cba1f4f9f..d4712d4187 100644 --- a/modules/@angular/compiler/src/template_parser/template_parser.ts +++ b/modules/@angular/compiler/src/template_parser/template_parser.ts @@ -11,7 +11,6 @@ import {CompileDirectiveMetadata, CompileDirectiveSummary, CompilePipeSummary, C import {CompilerConfig} from '../config'; import {AST, ASTWithSource, EmptyExpr} from '../expression_parser/ast'; import {Parser} from '../expression_parser/parser'; -import {isPresent} from '../facade/lang'; import {I18NHtmlParser} from '../i18n/i18n_html_parser'; import {Identifiers, createIdentifierToken, identifierToken} from '../identifiers'; import {CompilerInjectable} from '../injectable'; @@ -295,7 +294,7 @@ class TemplateParseVisitor implements html.Visitor { prefixToken = normalizedName.substring(TEMPLATE_ATTR_PREFIX.length) + ':'; } - const hasTemplateBinding = isPresent(templateBindingsSource); + const hasTemplateBinding = templateBindingsSource != null; if (hasTemplateBinding) { if (hasInlineTemplates) { this._reportError( @@ -338,7 +337,7 @@ class TemplateParseVisitor implements html.Visitor { isTemplateElement ? parent.providerContext : providerContext)); providerContext.afterElement(); // Override the actual selector when the `ngProjectAs` attribute is provided - const projectionSelector = isPresent(preparsedElement.projectAs) ? + const projectionSelector = preparsedElement.projectAs != null ? CssSelector.parse(preparsedElement.projectAs)[0] : elementCssSelector; const ngContentIndex = parent.findNgContentIndex(projectionSelector); @@ -415,7 +414,7 @@ class TemplateParseVisitor implements html.Visitor { if (bindParts !== null) { hasBinding = true; - if (isPresent(bindParts[KW_BIND_IDX])) { + if (bindParts[KW_BIND_IDX] != null) { this._bindingParser.parsePropertyBinding( bindParts[IDENT_KW_IDX], value, false, srcSpan, targetMatchableAttrs, targetProps); @@ -698,7 +697,7 @@ class TemplateParseVisitor implements html.Visitor { }); events.forEach(event => { - if (isPresent(event.target) || !allDirectiveEvents.has(event.name)) { + if (event.target != null || !allDirectiveEvents.has(event.name)) { this._reportError( `Event binding ${event.fullName} not emitted by any directive on an embedded template. Make sure that the event name is spelled correctly and all directives are listed in the "@NgModule.declarations".`, event.sourceSpan); @@ -811,7 +810,7 @@ class ElementContext { this._ngContentIndexMatcher.match( selector, (selector, ngContentIndex) => { ngContentIndices.push(ngContentIndex); }); ngContentIndices.sort(); - if (isPresent(this._wildcardNgContentIndex)) { + if (this._wildcardNgContentIndex != null) { ngContentIndices.push(this._wildcardNgContentIndex); } return ngContentIndices.length > 0 ? ngContentIndices[0] : null; @@ -882,4 +881,4 @@ function isTemplate( return false; } -} \ No newline at end of file +} diff --git a/modules/@angular/compiler/src/url_resolver.ts b/modules/@angular/compiler/src/url_resolver.ts index e800ec8137..55ecdf9d1b 100644 --- a/modules/@angular/compiler/src/url_resolver.ts +++ b/modules/@angular/compiler/src/url_resolver.ts @@ -8,7 +8,6 @@ import {Inject, InjectionToken, PACKAGE_ROOT_URL} from '@angular/core'; -import {isBlank, isPresent} from './facade/lang'; import {CompilerInjectable} from './injectable'; @@ -62,12 +61,12 @@ export class UrlResolver { */ resolve(baseUrl: string, url: string): string { let resolvedUrl = url; - if (isPresent(baseUrl) && baseUrl.length > 0) { + if (baseUrl != null && baseUrl.length > 0) { resolvedUrl = _resolveUrl(baseUrl, resolvedUrl); } const resolvedParts = _split(resolvedUrl); let prefix = this._packagePrefix; - if (isPresent(prefix) && isPresent(resolvedParts) && + if (prefix != null && resolvedParts != null && resolvedParts[_ComponentIndex.Scheme] == 'package') { let path = resolvedParts[_ComponentIndex.Path]; prefix = prefix.replace(/\/+$/, ''); @@ -111,33 +110,33 @@ function _buildFromEncodedParts( opt_path?: string, opt_queryData?: string, opt_fragment?: string): string { const out: string[] = []; - if (isPresent(opt_scheme)) { + if (opt_scheme != null) { out.push(opt_scheme + ':'); } - if (isPresent(opt_domain)) { + if (opt_domain != null) { out.push('//'); - if (isPresent(opt_userInfo)) { + if (opt_userInfo != null) { out.push(opt_userInfo + '@'); } out.push(opt_domain); - if (isPresent(opt_port)) { + if (opt_port != null) { out.push(':' + opt_port); } } - if (isPresent(opt_path)) { + if (opt_path != null) { out.push(opt_path); } - if (isPresent(opt_queryData)) { + if (opt_queryData != null) { out.push('?' + opt_queryData); } - if (isPresent(opt_fragment)) { + if (opt_fragment != null) { out.push('#' + opt_fragment); } @@ -309,7 +308,7 @@ function _removeDotSegments(path: string): string { */ function _joinAndCanonicalizePath(parts: any[]): string { let path = parts[_ComponentIndex.Path]; - path = isBlank(path) ? '' : _removeDotSegments(path); + path = path == null ? '' : _removeDotSegments(path); parts[_ComponentIndex.Path] = path; return _buildFromEncodedParts( @@ -327,14 +326,14 @@ function _resolveUrl(base: string, url: string): string { const parts = _split(encodeURI(url)); const baseParts = _split(base); - if (isPresent(parts[_ComponentIndex.Scheme])) { + if (parts[_ComponentIndex.Scheme] != null) { return _joinAndCanonicalizePath(parts); } else { parts[_ComponentIndex.Scheme] = baseParts[_ComponentIndex.Scheme]; } for (let i = _ComponentIndex.Scheme; i <= _ComponentIndex.Port; i++) { - if (isBlank(parts[i])) { + if (parts[i] == null) { parts[i] = baseParts[i]; } } @@ -344,7 +343,7 @@ function _resolveUrl(base: string, url: string): string { } let path = baseParts[_ComponentIndex.Path]; - if (isBlank(path)) path = '/'; + if (path == null) path = '/'; const index = path.lastIndexOf('/'); path = path.substring(0, index + 1) + parts[_ComponentIndex.Path]; parts[_ComponentIndex.Path] = path; diff --git a/modules/@angular/compiler/src/util.ts b/modules/@angular/compiler/src/util.ts index e2190afa02..2207201790 100644 --- a/modules/@angular/compiler/src/util.ts +++ b/modules/@angular/compiler/src/util.ts @@ -6,7 +6,6 @@ * found in the LICENSE file at https://angular.io/license */ -import {isPrimitive, isStrictStringMap} from './facade/lang'; export const MODULE_SUFFIX = ''; const CAMEL_CASE_REGEXP = /([A-Z])/g; @@ -43,7 +42,8 @@ export function visitValue(value: any, visitor: ValueVisitor, context: any): any return visitor.visitStringMap(<{[key: string]: any}>value, context); } - if (value == null || isPrimitive(value)) { + if (value == null || typeof value == 'string' || typeof value == 'number' || + typeof value == 'boolean') { return visitor.visitPrimitive(value, context); } @@ -89,3 +89,12 @@ const ERROR_SYNTAX_ERROR = 'ngSyntaxError'; export function isSyntaxError(error: Error): boolean { return (error as any)[ERROR_SYNTAX_ERROR]; } + +export function escapeRegExp(s: string): string { + return s.replace(/([.*+?^=!:${}()|[\]\/\\])/g, '\\$1'); +} + +const STRING_MAP_PROTO = Object.getPrototypeOf({}); +function isStrictStringMap(obj: any): boolean { + return typeof obj === 'object' && obj !== null && Object.getPrototypeOf(obj) === STRING_MAP_PROTO; +} diff --git a/modules/@angular/compiler/test/css_parser/css_lexer_spec.ts b/modules/@angular/compiler/test/css_parser/css_lexer_spec.ts index c7763c1a4c..616b092a22 100644 --- a/modules/@angular/compiler/test/css_parser/css_lexer_spec.ts +++ b/modules/@angular/compiler/test/css_parser/css_lexer_spec.ts @@ -8,7 +8,6 @@ import {describe, expect, it} from '../../../core/testing/testing_internal'; import {CssLexer, CssLexerMode, CssToken, CssTokenType, cssScannerError, getRawMessage, getToken} from '../../src/css_parser/css_lexer'; -import {isPresent} from '../../src/facade/lang'; export function main() { function tokenize( @@ -21,7 +20,7 @@ export function main() { let output = scanner.scan(); while (output != null) { const error = output.error; - if (isPresent(error)) { + if (error != null) { throw cssScannerError(getToken(error), getRawMessage(error)); } tokens.push(output.token); diff --git a/modules/@angular/compiler/test/css_parser/css_visitor_spec.ts b/modules/@angular/compiler/test/css_parser/css_visitor_spec.ts index a69605e974..53325ad0e7 100644 --- a/modules/@angular/compiler/test/css_parser/css_visitor_spec.ts +++ b/modules/@angular/compiler/test/css_parser/css_visitor_spec.ts @@ -10,7 +10,6 @@ import {beforeEach, describe, expect, it} from '../../../core/testing/testing_internal'; import {CssAst, CssAstVisitor, CssAtRulePredicateAst, CssBlockAst, CssDefinitionAst, CssInlineRuleAst, CssKeyframeDefinitionAst, CssKeyframeRuleAst, CssMediaQueryRuleAst, CssPseudoSelectorAst, CssRuleAst, CssSelectorAst, CssSelectorRuleAst, CssSimpleSelectorAst, CssStyleSheetAst, CssStyleValueAst, CssStylesBlockAst, CssUnknownRuleAst, CssUnknownTokenListAst} from '../../src/css_parser/css_ast'; import {BlockType, CssParseError, CssParser, CssToken} from '../../src/css_parser/css_parser'; -import {isPresent} from '../../src/facade/lang'; function _assertTokens(tokens: CssToken[], valuesArr: string[]): void { expect(tokens.length).toEqual(valuesArr.length); diff --git a/modules/@angular/compiler/test/expression_parser/parser_spec.ts b/modules/@angular/compiler/test/expression_parser/parser_spec.ts index 4ead549a6d..f5d42723e0 100644 --- a/modules/@angular/compiler/test/expression_parser/parser_spec.ts +++ b/modules/@angular/compiler/test/expression_parser/parser_spec.ts @@ -11,7 +11,6 @@ import {Lexer} from '@angular/compiler/src/expression_parser/lexer'; import {Parser, SplitInterpolation, TemplateBindingParseResult} from '@angular/compiler/src/expression_parser/parser'; import {expect} from '@angular/platform-browser/testing/matchers'; -import {isBlank, isPresent} from '../../src/facade/lang'; import {unparse} from './unparser'; import {validate} from './validator'; @@ -50,21 +49,21 @@ export function main() { function checkInterpolation(exp: string, expected?: string) { const ast = parseInterpolation(exp); - if (isBlank(expected)) expected = exp; + if (expected == null) expected = exp; expect(unparse(ast)).toEqual(expected); validate(ast); } function checkBinding(exp: string, expected?: string) { const ast = parseBinding(exp); - if (isBlank(expected)) expected = exp; + if (expected == null) expected = exp; expect(unparse(ast)).toEqual(expected); validate(ast); } function checkAction(exp: string, expected?: string) { const ast = parseAction(exp); - if (isBlank(expected)) expected = exp; + if (expected == null) expected = exp; expect(unparse(ast)).toEqual(expected); validate(ast); } @@ -321,9 +320,9 @@ export function main() { function keyValues(templateBindings: any[]) { return templateBindings.map(binding => { if (binding.keyIsVar) { - return 'let ' + binding.key + (isBlank(binding.name) ? '=null' : '=' + binding.name); + return 'let ' + binding.key + (binding.name == null ? '=null' : '=' + binding.name); } else { - return binding.key + (isBlank(binding.expression) ? '' : `=${binding.expression}`); + return binding.key + (binding.expression == null ? '' : `=${binding.expression}`); } }); } @@ -335,7 +334,7 @@ export function main() { function exprSources(templateBindings: any[]) { return templateBindings.map( - binding => isPresent(binding.expression) ? binding.expression.source : null); + binding => binding.expression != null ? binding.expression.source : null); } it('should parse an empty string', () => { expect(parseTemplateBindings('')).toEqual([]); }); diff --git a/modules/@angular/compiler/test/i18n/serializers/xliff_spec.ts b/modules/@angular/compiler/test/i18n/serializers/xliff_spec.ts index e8a81b6611..18603a07fb 100644 --- a/modules/@angular/compiler/test/i18n/serializers/xliff_spec.ts +++ b/modules/@angular/compiler/test/i18n/serializers/xliff_spec.ts @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -import {escapeRegExp} from '@angular/core/src/facade/lang'; +import {escapeRegExp} from '@angular/compiler/src/util'; import {serializeNodes} from '../../../src/i18n/digest'; import {MessageBundle} from '../../../src/i18n/message_bundle'; diff --git a/modules/@angular/compiler/test/i18n/serializers/xtb_spec.ts b/modules/@angular/compiler/test/i18n/serializers/xtb_spec.ts index 65b1b05966..27c01b4127 100644 --- a/modules/@angular/compiler/test/i18n/serializers/xtb_spec.ts +++ b/modules/@angular/compiler/test/i18n/serializers/xtb_spec.ts @@ -6,8 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -import {escapeRegExp} from '@angular/core/src/facade/lang'; - +import {escapeRegExp} from '@angular/compiler/src/util'; import {serializeNodes} from '../../../src/i18n/digest'; import * as i18n from '../../../src/i18n/i18n_ast'; import {Xtb} from '../../../src/i18n/serializers/xtb'; diff --git a/modules/@angular/compiler/test/metadata_resolver_spec.ts b/modules/@angular/compiler/test/metadata_resolver_spec.ts index 70328dc020..8d57cee687 100644 --- a/modules/@angular/compiler/test/metadata_resolver_spec.ts +++ b/modules/@angular/compiler/test/metadata_resolver_spec.ts @@ -7,12 +7,10 @@ */ import {TEST_COMPILER_PROVIDERS} from '@angular/compiler/testing/test_bindings'; -import {AfterContentChecked, AfterContentInit, AfterViewChecked, AfterViewInit, ChangeDetectionStrategy, Component, Directive, DoCheck, Injectable, NgModule, OnChanges, OnDestroy, OnInit, Pipe, SimpleChanges, ViewEncapsulation} from '@angular/core'; +import {AfterContentChecked, AfterContentInit, AfterViewChecked, AfterViewInit, ChangeDetectionStrategy, Component, Directive, DoCheck, Injectable, NgModule, OnChanges, OnDestroy, OnInit, Pipe, SimpleChanges, ViewEncapsulation, ɵstringify as stringify} from '@angular/core'; import {LIFECYCLE_HOOKS_VALUES} from '@angular/core/src/metadata/lifecycle_hooks'; import {TestBed, async, inject} from '@angular/core/testing'; - import {identifierName} from '../src/compile_metadata'; -import {stringify} from '../src/facade/lang'; import {CompileMetadataResolver} from '../src/metadata_resolver'; import {ResourceLoader} from '../src/resource_loader'; import {MockResourceLoader} from '../testing/resource_loader_mock'; diff --git a/modules/@angular/compiler/test/ng_module_resolver_spec.ts b/modules/@angular/compiler/test/ng_module_resolver_spec.ts index e99d544c08..c9a67ea959 100644 --- a/modules/@angular/compiler/test/ng_module_resolver_spec.ts +++ b/modules/@angular/compiler/test/ng_module_resolver_spec.ts @@ -7,8 +7,8 @@ */ import {NgModuleResolver} from '@angular/compiler/src/ng_module_resolver'; +import {ɵstringify as stringify} from '@angular/core'; import {NgModule} from '@angular/core/src/metadata'; -import {stringify} from '../src/facade/lang'; class SomeClass1 {} class SomeClass2 {} diff --git a/modules/@angular/compiler/test/pipe_resolver_spec.ts b/modules/@angular/compiler/test/pipe_resolver_spec.ts index 3d9003ff86..6b7a6b810a 100644 --- a/modules/@angular/compiler/test/pipe_resolver_spec.ts +++ b/modules/@angular/compiler/test/pipe_resolver_spec.ts @@ -7,8 +7,8 @@ */ import {PipeResolver} from '@angular/compiler/src/pipe_resolver'; +import {ɵstringify as stringify} from '@angular/core'; import {Pipe} from '@angular/core/src/metadata'; -import {stringify} from '../src/facade/lang'; @Pipe({name: 'somePipe', pure: true}) class SomePipe { diff --git a/modules/@angular/compiler/test/resource_loader_mock_spec.ts b/modules/@angular/compiler/test/resource_loader_mock_spec.ts index 00efa3e644..af1532bd95 100644 --- a/modules/@angular/compiler/test/resource_loader_mock_spec.ts +++ b/modules/@angular/compiler/test/resource_loader_mock_spec.ts @@ -8,7 +8,6 @@ import {MockResourceLoader} from '@angular/compiler/testing/resource_loader_mock'; import {AsyncTestCompleter, beforeEach, describe, expect, inject, it} from '@angular/core/testing/testing_internal'; -import {isPresent} from '../src/facade/lang'; export function main() { describe('MockResourceLoader', () => { @@ -23,7 +22,7 @@ export function main() { throw `Unexpected response ${url} -> ${text}`; } else { expect(text).toEqual(response); - if (isPresent(done)) done(); + if (done != null) done(); } return text; } @@ -33,7 +32,7 @@ export function main() { throw `Unexpected error ${url}`; } else { expect(error).toEqual(`Failed to load ${url}`); - if (isPresent(done)) done(); + if (done != null) done(); } return error; } diff --git a/modules/@angular/compiler/test/runtime_compiler_spec.ts b/modules/@angular/compiler/test/runtime_compiler_spec.ts index 80127bd27d..4d55943758 100644 --- a/modules/@angular/compiler/test/runtime_compiler_spec.ts +++ b/modules/@angular/compiler/test/runtime_compiler_spec.ts @@ -7,11 +7,9 @@ */ import {DirectiveResolver, ResourceLoader} from '@angular/compiler'; -import {Compiler, Component, Injector, NgModule, NgModuleFactory, ɵViewMetadata as ViewMetadata} from '@angular/core'; +import {Compiler, Component, Injector, NgModule, NgModuleFactory, ɵViewMetadata as ViewMetadata, ɵstringify as stringify} from '@angular/core'; import {TestBed, async, fakeAsync, inject, tick} from '@angular/core/testing'; import {expect} from '@angular/platform-browser/testing/matchers'; - -import {stringify} from '../src/facade/lang'; import {MockDirectiveResolver} from '../testing/index'; import {SpyResourceLoader} from './spies'; diff --git a/modules/@angular/compiler/test/util_spec.ts b/modules/@angular/compiler/test/util_spec.ts index 6bae97cc26..642f931e65 100644 --- a/modules/@angular/compiler/test/util_spec.ts +++ b/modules/@angular/compiler/test/util_spec.ts @@ -9,7 +9,7 @@ import {fakeAsync} from '@angular/core/testing/fake_async'; import {describe, expect, it} from '@angular/core/testing/testing_internal'; -import {SyncAsyncResult, splitAtColon} from '../src/util'; +import {SyncAsyncResult, escapeRegExp, splitAtColon} from '../src/util'; export function main() { describe('util', () => { @@ -36,5 +36,14 @@ export function main() { expect(splitAtColon('ab', ['c', 'd'])).toEqual(['c', 'd']); }); }); + + describe('RegExp', () => { + it('should escape regexp', () => { + expect(new RegExp(escapeRegExp('b')).exec('abc')).toBeTruthy(); + expect(new RegExp(escapeRegExp('b')).exec('adc')).toBeFalsy(); + expect(new RegExp(escapeRegExp('a.b')).exec('a.b')).toBeTruthy(); + expect(new RegExp(escapeRegExp('a.b')).exec('axb')).toBeFalsy(); + }); + }); }); } diff --git a/modules/@angular/compiler/testing/directive_resolver_mock.ts b/modules/@angular/compiler/testing/directive_resolver_mock.ts index e4b37dac6b..75eeccc1eb 100644 --- a/modules/@angular/compiler/testing/directive_resolver_mock.ts +++ b/modules/@angular/compiler/testing/directive_resolver_mock.ts @@ -7,7 +7,6 @@ */ import {DirectiveResolver} from '@angular/compiler'; import {Compiler, Component, Directive, Injectable, Injector, Provider, Type, resolveForwardRef, ɵViewMetadata as ViewMetadata} from '@angular/core'; -import {isPresent} from './facade/lang'; @@ -42,14 +41,14 @@ export class MockDirectiveResolver extends DirectiveResolver { const viewProviderOverrides = this._viewProviderOverrides.get(type); let providers = metadata.providers; - if (isPresent(providerOverrides)) { + if (providerOverrides != null) { const originalViewProviders: Provider[] = metadata.providers || []; providers = originalViewProviders.concat(providerOverrides); } if (metadata instanceof Component) { let viewProviders = metadata.viewProviders; - if (isPresent(viewProviderOverrides)) { + if (viewProviderOverrides != null) { const originalViewProviders: Provider[] = metadata.viewProviders || []; viewProviders = originalViewProviders.concat(viewProviderOverrides); } @@ -63,7 +62,7 @@ export class MockDirectiveResolver extends DirectiveResolver { let templateUrl = view.templateUrl; let inlineTemplate = this._inlineTemplates.get(type); - if (isPresent(inlineTemplate)) { + if (inlineTemplate != null) { templateUrl = null; } else { inlineTemplate = view.template; @@ -137,7 +136,7 @@ export class MockDirectiveResolver extends DirectiveResolver { } function flattenArray(tree: any[], out: Array|any[]>): void { - if (!isPresent(tree)) return; + if (tree == null) return; for (let i = 0; i < tree.length; i++) { const item = resolveForwardRef(tree[i]); if (Array.isArray(item)) { diff --git a/modules/@angular/compiler/testing/facade b/modules/@angular/compiler/testing/facade deleted file mode 120000 index e084c803c6..0000000000 --- a/modules/@angular/compiler/testing/facade +++ /dev/null @@ -1 +0,0 @@ -../../facade/src \ No newline at end of file diff --git a/modules/@angular/compiler/testing/metadata_overrider.ts b/modules/@angular/compiler/testing/metadata_overrider.ts index bb6539aed4..6c5858fa2f 100644 --- a/modules/@angular/compiler/testing/metadata_overrider.ts +++ b/modules/@angular/compiler/testing/metadata_overrider.ts @@ -6,8 +6,8 @@ * found in the LICENSE file at https://angular.io/license */ +import {ɵstringify as stringify} from '@angular/core'; import {MetadataOverride} from '@angular/core/testing'; -import {stringify} from './facade/lang'; type StringMap = { [key: string]: any diff --git a/modules/@angular/compiler/testing/resource_loader_mock.ts b/modules/@angular/compiler/testing/resource_loader_mock.ts index 78d53d6829..ba9504e006 100644 --- a/modules/@angular/compiler/testing/resource_loader_mock.ts +++ b/modules/@angular/compiler/testing/resource_loader_mock.ts @@ -7,7 +7,6 @@ */ import {ResourceLoader} from '@angular/compiler'; -import {isBlank} from './facade/lang'; /** * A mock implementation of {@link ResourceLoader} that allows outgoing requests to be mocked @@ -110,7 +109,7 @@ class _PendingRequest { } complete(response: string) { - if (isBlank(response)) { + if (response == null) { this.reject(`Failed to load ${this.url}`); } else { this.resolve(response); diff --git a/modules/@angular/core/src/application_ref.ts b/modules/@angular/core/src/application_ref.ts index b5204d7c72..3d9c06c03a 100644 --- a/modules/@angular/core/src/application_ref.ts +++ b/modules/@angular/core/src/application_ref.ts @@ -12,12 +12,9 @@ import {Subject} from 'rxjs/Subject'; import {Subscription} from 'rxjs/Subscription'; import {merge} from 'rxjs/observable/merge'; import {share} from 'rxjs/operator/share'; - import {ErrorHandler} from '../src/error_handler'; -import {stringify} from '../src/facade/lang'; -import {scheduleMicroTask} from '../src/util'; +import {scheduleMicroTask, stringify} from '../src/util'; import {isPromise} from '../src/util/lang'; - import {ApplicationInitStatus} from './application_init'; import {APP_BOOTSTRAP_LISTENER, PLATFORM_INITIALIZER} from './application_tokens'; import {Console} from './console'; diff --git a/modules/@angular/core/src/change_detection/change_detection.ts b/modules/@angular/core/src/change_detection/change_detection.ts index 46da439c6e..db43f81e07 100644 --- a/modules/@angular/core/src/change_detection/change_detection.ts +++ b/modules/@angular/core/src/change_detection/change_detection.ts @@ -12,7 +12,7 @@ import {IterableDifferFactory, IterableDiffers} from './differs/iterable_differs import {KeyValueDifferFactory, KeyValueDiffers} from './differs/keyvalue_differs'; export {SimpleChanges} from '../metadata/lifecycle_hooks'; -export {SimpleChange, ValueUnwrapper, WrappedValue, devModeEqual, looseIdentical} from './change_detection_util'; +export {SimpleChange, ValueUnwrapper, WrappedValue, devModeEqual} from './change_detection_util'; export {ChangeDetectorRef} from './change_detector_ref'; export {ChangeDetectionStrategy, ChangeDetectorStatus, isDefaultChangeDetectionStrategy} from './constants'; export {DefaultIterableDifferFactory} from './differs/default_iterable_differ'; diff --git a/modules/@angular/core/src/change_detection/change_detection_util.ts b/modules/@angular/core/src/change_detection/change_detection_util.ts index b672dc5a38..9f68ba4f7e 100644 --- a/modules/@angular/core/src/change_detection/change_detection_util.ts +++ b/modules/@angular/core/src/change_detection/change_detection_util.ts @@ -6,21 +6,21 @@ * found in the LICENSE file at https://angular.io/license */ -import {isJsObject, isPrimitive, looseIdentical} from '../facade/lang'; -import {getSymbolIterator} from '../util'; - -export {looseIdentical} from '../facade/lang'; +import {getSymbolIterator, looseIdentical} from '../util'; export function devModeEqual(a: any, b: any): boolean { - if (isListLikeIterable(a) && isListLikeIterable(b)) { + const isListLikeIterableA = isListLikeIterable(a); + const isListLikeIterableB = isListLikeIterable(b); + if (isListLikeIterableA && isListLikeIterableB) { return areIterablesEqual(a, b, devModeEqual); - - } else if ( - !isListLikeIterable(a) && !isPrimitive(a) && !isListLikeIterable(b) && !isPrimitive(b)) { - return true; - } else { - return looseIdentical(a, b); + const isAObject = a && (typeof a === 'object' || typeof a === 'function'); + const isBObject = b && (typeof b === 'object' || typeof b === 'function'); + if (!isListLikeIterableA && isAObject && !isListLikeIterableB && isBObject) { + return true; + } else { + return looseIdentical(a, b); + } } } @@ -113,3 +113,7 @@ export function iterateListLike(obj: any, fn: (p: any) => any) { } } } + +export function isJsObject(o: any): boolean { + return o !== null && (typeof o === 'function' || typeof o === 'object'); +} diff --git a/modules/@angular/core/src/change_detection/constants.ts b/modules/@angular/core/src/change_detection/constants.ts index 2ac1ecf136..03f4104f3f 100644 --- a/modules/@angular/core/src/change_detection/constants.ts +++ b/modules/@angular/core/src/change_detection/constants.ts @@ -6,7 +6,6 @@ * found in the LICENSE file at https://angular.io/license */ -import {isBlank} from '../facade/lang'; /** * Describes within the change detector which strategy will be used the next time change @@ -68,6 +67,6 @@ export enum ChangeDetectorStatus { export function isDefaultChangeDetectionStrategy(changeDetectionStrategy: ChangeDetectionStrategy): boolean { - return isBlank(changeDetectionStrategy) || + return changeDetectionStrategy == null || changeDetectionStrategy === ChangeDetectionStrategy.Default; } diff --git a/modules/@angular/core/src/change_detection/differs/default_iterable_differ.ts b/modules/@angular/core/src/change_detection/differs/default_iterable_differ.ts index bfc35a6497..4b94b87270 100644 --- a/modules/@angular/core/src/change_detection/differs/default_iterable_differ.ts +++ b/modules/@angular/core/src/change_detection/differs/default_iterable_differ.ts @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -import {isBlank, looseIdentical, stringify} from '../../facade/lang'; +import {looseIdentical, stringify} from '../../util'; import {isListLikeIterable, iterateListLike} from '../change_detection_util'; import {ChangeDetectorRef} from '../change_detector_ref'; @@ -155,7 +155,7 @@ export class DefaultIterableDiffer implements IterableDiffer, IterableChan } diff(collection: NgIterable): DefaultIterableDiffer { - if (isBlank(collection)) collection = []; + if (collection == null) collection = []; if (!isListLikeIterable(collection)) { throw new Error(`Error trying to diff '${collection}'`); } diff --git a/modules/@angular/core/src/change_detection/differs/default_keyvalue_differ.ts b/modules/@angular/core/src/change_detection/differs/default_keyvalue_differ.ts index 860da72620..6c798daf7f 100644 --- a/modules/@angular/core/src/change_detection/differs/default_keyvalue_differ.ts +++ b/modules/@angular/core/src/change_detection/differs/default_keyvalue_differ.ts @@ -6,7 +6,8 @@ * found in the LICENSE file at https://angular.io/license */ -import {isJsObject, looseIdentical, stringify} from '../../facade/lang'; +import {looseIdentical, stringify} from '../../util'; +import {isJsObject} from '../change_detection_util'; import {ChangeDetectorRef} from '../change_detector_ref'; import {KeyValueChangeRecord, KeyValueChanges, KeyValueDiffer, KeyValueDifferFactory} from './keyvalue_differs'; diff --git a/modules/@angular/core/src/change_detection/differs/iterable_differs.ts b/modules/@angular/core/src/change_detection/differs/iterable_differs.ts index bede76228d..b111f3d23d 100644 --- a/modules/@angular/core/src/change_detection/differs/iterable_differs.ts +++ b/modules/@angular/core/src/change_detection/differs/iterable_differs.ts @@ -7,7 +7,6 @@ */ import {Optional, Provider, SkipSelf} from '../../di'; -import {getTypeNameForDebugging, isPresent} from '../../facade/lang'; import {ChangeDetectorRef} from '../change_detector_ref'; /** @@ -158,7 +157,7 @@ export class IterableDiffers { constructor(factories: IterableDifferFactory[]) { this.factories = factories; } static create(factories: IterableDifferFactory[], parent?: IterableDiffers): IterableDiffers { - if (isPresent(parent)) { + if (parent != null) { const copied = parent.factories.slice(); factories = factories.concat(copied); return new IterableDiffers(factories); @@ -205,7 +204,7 @@ export class IterableDiffers { find(iterable: any): IterableDifferFactory { const factory = this.factories.find(f => f.supports(iterable)); - if (isPresent(factory)) { + if (factory != null) { return factory; } else { throw new Error( @@ -213,3 +212,7 @@ export class IterableDiffers { } } } + +export function getTypeNameForDebugging(type: any): string { + return type['name'] || typeof type; +} diff --git a/modules/@angular/core/src/console.ts b/modules/@angular/core/src/console.ts index 4acc013f6b..bc30a29fb8 100644 --- a/modules/@angular/core/src/console.ts +++ b/modules/@angular/core/src/console.ts @@ -7,11 +7,16 @@ */ import {Injectable} from './di'; -import {print, warn} from './facade/lang'; @Injectable() export class Console { - log(message: string): void { print(message); } + log(message: string): void { + // tslint:disable-next-line:no-console + console.log(message); + } // Note: for reporting errors use `DOM.logError()` as it is platform specific - warn(message: string): void { warn(message); } + warn(message: string): void { + // tslint:disable-next-line:no-console + console.warn(message); + } } diff --git a/modules/@angular/core/src/core_private_export.ts b/modules/@angular/core/src/core_private_export.ts index 20e09182a4..86245cf72a 100644 --- a/modules/@angular/core/src/core_private_export.ts +++ b/modules/@angular/core/src/core_private_export.ts @@ -23,6 +23,6 @@ export {ReflectionCapabilities as ɵReflectionCapabilities} from './reflection/r export {ReflectorReader as ɵReflectorReader} from './reflection/reflector_reader'; export {GetterFn as ɵGetterFn, MethodFn as ɵMethodFn, SetterFn as ɵSetterFn} from './reflection/types'; export {DirectRenderer as ɵDirectRenderer, RenderDebugInfo as ɵRenderDebugInfo} from './render/api'; -export {global as ɵglobal} from './util'; +export {global as ɵglobal, looseIdentical as ɵlooseIdentical, stringify as ɵstringify} from './util'; export {makeDecorator as ɵmakeDecorator} from './util/decorators'; export {isObservable as ɵisObservable, isPromise as ɵisPromise, merge as ɵmerge} from './util/lang'; diff --git a/modules/@angular/core/src/di/forward_ref.ts b/modules/@angular/core/src/di/forward_ref.ts index d3adb24170..8800543923 100644 --- a/modules/@angular/core/src/di/forward_ref.ts +++ b/modules/@angular/core/src/di/forward_ref.ts @@ -6,8 +6,9 @@ * found in the LICENSE file at https://angular.io/license */ -import {stringify} from '../facade/lang'; import {Type} from '../type'; +import {stringify} from '../util'; + /** diff --git a/modules/@angular/core/src/di/injector.ts b/modules/@angular/core/src/di/injector.ts index 8550adfa11..f69f11591a 100644 --- a/modules/@angular/core/src/di/injector.ts +++ b/modules/@angular/core/src/di/injector.ts @@ -6,8 +6,8 @@ * found in the LICENSE file at https://angular.io/license */ -import {stringify} from '../facade/lang'; import {Type} from '../type'; +import {stringify} from '../util'; import {InjectionToken} from './injection_token'; diff --git a/modules/@angular/core/src/di/reflective_errors.ts b/modules/@angular/core/src/di/reflective_errors.ts index 6023685d02..2360e84f24 100644 --- a/modules/@angular/core/src/di/reflective_errors.ts +++ b/modules/@angular/core/src/di/reflective_errors.ts @@ -8,8 +8,8 @@ import {wrappedError} from '../error_handler'; import {ERROR_ORIGINAL_ERROR, getOriginalError} from '../errors'; -import {stringify} from '../facade/lang'; import {Type} from '../type'; +import {stringify} from '../util'; import {ReflectiveInjector} from './reflective_injector'; import {ReflectiveKey} from './reflective_key'; diff --git a/modules/@angular/core/src/di/reflective_key.ts b/modules/@angular/core/src/di/reflective_key.ts index 0e797d26c7..edf478e2f8 100644 --- a/modules/@angular/core/src/di/reflective_key.ts +++ b/modules/@angular/core/src/di/reflective_key.ts @@ -6,8 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -import {stringify} from '../facade/lang'; - +import {stringify} from '../util'; import {resolveForwardRef} from './forward_ref'; diff --git a/modules/@angular/core/src/facade b/modules/@angular/core/src/facade deleted file mode 120000 index e084c803c6..0000000000 --- a/modules/@angular/core/src/facade +++ /dev/null @@ -1 +0,0 @@ -../../facade/src \ No newline at end of file diff --git a/modules/@angular/core/src/linker/component_factory_resolver.ts b/modules/@angular/core/src/linker/component_factory_resolver.ts index 61c413a548..97b62d1b44 100644 --- a/modules/@angular/core/src/linker/component_factory_resolver.ts +++ b/modules/@angular/core/src/linker/component_factory_resolver.ts @@ -6,8 +6,8 @@ * found in the LICENSE file at https://angular.io/license */ -import {stringify} from '../facade/lang'; import {Type} from '../type'; +import {stringify} from '../util'; import {ComponentFactory} from './component_factory'; diff --git a/modules/@angular/core/src/linker/ng_module_factory.ts b/modules/@angular/core/src/linker/ng_module_factory.ts index d6700fd67a..97c8e90b11 100644 --- a/modules/@angular/core/src/linker/ng_module_factory.ts +++ b/modules/@angular/core/src/linker/ng_module_factory.ts @@ -7,8 +7,9 @@ */ import {Injector, THROW_IF_NOT_FOUND} from '../di/injector'; -import {stringify} from '../facade/lang'; import {Type} from '../type'; +import {stringify} from '../util'; + import {ComponentFactory} from './component_factory'; import {CodegenComponentFactoryResolver, ComponentFactoryResolver} from './component_factory_resolver'; diff --git a/modules/@angular/core/src/reflection/reflection_capabilities.ts b/modules/@angular/core/src/reflection/reflection_capabilities.ts index 063d9e7fa5..ca78a6dbaf 100644 --- a/modules/@angular/core/src/reflection/reflection_capabilities.ts +++ b/modules/@angular/core/src/reflection/reflection_capabilities.ts @@ -6,9 +6,8 @@ * found in the LICENSE file at https://angular.io/license */ -import {isPresent, stringify} from '../facade/lang'; import {Type, isType} from '../type'; -import {global} from '../util'; +import {global, stringify} from '../util'; import {PlatformReflectionCapabilities} from './platform_reflection_capabilities'; import {GetterFn, MethodFn, SetterFn} from './types'; @@ -48,7 +47,7 @@ export class ReflectionCapabilities implements PlatformReflectionCapabilities { } else { result[i] = []; } - if (paramAnnotations && isPresent(paramAnnotations[i])) { + if (paramAnnotations && paramAnnotations[i] != null) { result[i] = result[i].concat(paramAnnotations[i]); } } @@ -87,7 +86,7 @@ export class ReflectionCapabilities implements PlatformReflectionCapabilities { } // API for metadata created by invoking the decorators. - if (isPresent(this._reflect) && isPresent(this._reflect.getOwnMetadata)) { + if (this._reflect != null && this._reflect.getOwnMetadata != null) { const paramAnnotations = this._reflect.getOwnMetadata('parameters', type); const paramTypes = this._reflect.getOwnMetadata('design:paramtypes', type); if (paramTypes || paramAnnotations) { diff --git a/modules/@angular/core/src/util.ts b/modules/@angular/core/src/util.ts index bba986bac8..217bb6ffff 100644 --- a/modules/@angular/core/src/util.ts +++ b/modules/@angular/core/src/util.ts @@ -24,7 +24,7 @@ declare const Symbol: any; let _symbolIterator: any = null; export function getSymbolIterator(): string|symbol { if (!_symbolIterator) { - var Symbol = _global['Symbol']; + const Symbol = _global['Symbol']; if (Symbol && Symbol.iterator) { _symbolIterator = Symbol.iterator; } else { @@ -45,3 +45,30 @@ export function getSymbolIterator(): string|symbol { export function scheduleMicroTask(fn: Function) { Zone.current.scheduleMicroTask('scheduleMicrotask', fn); } + +// JS has NaN !== NaN +export function looseIdentical(a: any, b: any): boolean { + return a === b || typeof a === 'number' && typeof b === 'number' && isNaN(a) && isNaN(b); +} + +export function stringify(token: any): string { + if (typeof token === 'string') { + return token; + } + + if (token == null) { + return '' + token; + } + + if (token.overriddenName) { + return `${token.overriddenName}`; + } + + if (token.name) { + return `${token.name}`; + } + + const res = token.toString(); + const newLineIndex = res.indexOf('\n'); + return newLineIndex === -1 ? res : res.substring(0, newLineIndex); +} diff --git a/modules/@angular/core/src/util/decorators.ts b/modules/@angular/core/src/util/decorators.ts index 36c76cffa7..a26ad2e476 100644 --- a/modules/@angular/core/src/util/decorators.ts +++ b/modules/@angular/core/src/util/decorators.ts @@ -6,9 +6,8 @@ * found in the LICENSE file at https://angular.io/license */ -import {stringify} from '../facade/lang'; import {Type} from '../type'; -import {global} from '../util'; +import {global, stringify} from '../util'; let _nextClassId = 0; const Reflect = global['Reflect']; diff --git a/modules/@angular/core/src/view/text.ts b/modules/@angular/core/src/view/text.ts index ae25850991..5819086f92 100644 --- a/modules/@angular/core/src/view/text.ts +++ b/modules/@angular/core/src/view/text.ts @@ -7,7 +7,7 @@ */ import {isDevMode} from '../application_ref'; -import {looseIdentical} from '../facade/lang'; +import {looseIdentical} from '../util'; import {BindingDef, BindingType, DebugContext, NodeData, NodeDef, NodeFlags, RootData, Services, TextData, ViewData, ViewFlags, asElementData, asTextData} from './types'; import {checkAndUpdateBinding, getParentRenderElement, sliceErrorStack} from './util'; diff --git a/modules/@angular/core/src/view/util.ts b/modules/@angular/core/src/view/util.ts index 9111896ade..211cef22db 100644 --- a/modules/@angular/core/src/view/util.ts +++ b/modules/@angular/core/src/view/util.ts @@ -10,12 +10,12 @@ import {isDevMode} from '../application_ref'; import {WrappedValue, devModeEqual} from '../change_detection/change_detection'; import {SimpleChange} from '../change_detection/change_detection_util'; import {Injector} from '../di'; -import {looseIdentical, stringify} from '../facade/lang'; import {TemplateRef} from '../linker/template_ref'; import {ViewContainerRef} from '../linker/view_container_ref'; import {ViewRef} from '../linker/view_ref'; import {ViewEncapsulation} from '../metadata/view'; import {Renderer, RendererTypeV2} from '../render/api'; +import {looseIdentical, stringify} from '../util'; import {expressionChangedAfterItHasBeenCheckedError, isViewDebugError, viewDestroyedError, viewWrappedDebugError} from './errors'; import {DebugContext, ElementData, NodeData, NodeDef, NodeFlags, QueryValueType, Services, ViewData, ViewDefinition, ViewDefinitionFactory, ViewFlags, ViewState, asElementData, asProviderData, asTextData} from './types'; @@ -389,4 +389,4 @@ function _toStringWithNull(v: any): string { } export const EMPTY_ARRAY: any[] = []; -export const EMPTY_MAP: {[key: string]: any} = {}; \ No newline at end of file +export const EMPTY_MAP: {[key: string]: any} = {}; diff --git a/modules/@angular/core/test/di/reflective_injector_spec.ts b/modules/@angular/core/test/di/reflective_injector_spec.ts index 09af2cf3ca..6371a3dedf 100644 --- a/modules/@angular/core/test/di/reflective_injector_spec.ts +++ b/modules/@angular/core/test/di/reflective_injector_spec.ts @@ -11,8 +11,7 @@ import {ReflectiveInjector_} from '@angular/core/src/di/reflective_injector'; import {ResolvedReflectiveProvider_} from '@angular/core/src/di/reflective_provider'; import {getOriginalError} from '@angular/core/src/errors'; import {expect} from '@angular/platform-browser/testing/matchers'; - -import {isPresent, stringify} from '../../src/facade/lang'; +import {stringify} from '../../src/util'; class Engine {} @@ -82,7 +81,7 @@ export function main() { function createInjector( providers: Provider[], parent: ReflectiveInjector = null): ReflectiveInjector_ { const resolvedProviders = ReflectiveInjector.resolve(providers.concat(dynamicProviders)); - if (isPresent(parent)) { + if (parent != null) { return parent.createChildFromResolved(resolvedProviders); } else { return ReflectiveInjector.fromResolvedProviders(resolvedProviders); diff --git a/modules/@angular/core/test/facade/observable_spec.ts b/modules/@angular/core/test/facade/observable_spec.ts deleted file mode 100644 index 1b9b387dd8..0000000000 --- a/modules/@angular/core/test/facade/observable_spec.ts +++ /dev/null @@ -1,63 +0,0 @@ -/** - * @license - * Copyright Google Inc. All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ - -import {AsyncTestCompleter, describe, expect, inject, it} from '@angular/core/testing/testing_internal'; -import {Observable} from 'rxjs/Observable'; - -export function main() { - describe('Observable', () => { - describe('#core', () => { - - it('should call next with values', - inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { - - const o = new Observable((sink: any /** TODO #9100 */) => { sink.next(1); }); - - o.subscribe(v => { - expect(v).toEqual(1); - async.done(); - }); - - })); - - it('should call next and then complete', - inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { - - const o = new Observable((sink: any /** TODO #9100 */) => { - sink.next(1); - sink.complete(); - }); - let nexted = false; - - o.subscribe( - v => { nexted = true; }, null, - () => { - expect(nexted).toBe(true); - async.done(); - }); - - })); - - it('should call error with errors', - inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { - - const o = new Observable((sink: any /** TODO #9100 */) => { sink.error('oh noes!'); }); - - o.subscribe( - v => { - - }, - (err) => { - expect(err).toEqual('oh noes!'); - async.done(); - }); - - })); - }); - }); -} diff --git a/modules/@angular/core/test/linker/integration_spec.ts b/modules/@angular/core/test/linker/integration_spec.ts index 5c3339aaa5..aa5902fd6c 100644 --- a/modules/@angular/core/test/linker/integration_spec.ts +++ b/modules/@angular/core/test/linker/integration_spec.ts @@ -22,8 +22,7 @@ import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter'; import {DOCUMENT} from '@angular/platform-browser/src/dom/dom_tokens'; import {dispatchEvent, el} from '@angular/platform-browser/testing/browser_util'; import {expect} from '@angular/platform-browser/testing/matchers'; - -import {stringify} from '../../src/facade/lang'; +import {stringify} from '../../src/util'; const ANCHOR_ELEMENT = new InjectionToken('AnchorElement'); diff --git a/modules/@angular/core/test/linker/ng_module_integration_spec.ts b/modules/@angular/core/test/linker/ng_module_integration_spec.ts index 55bbb298ae..fdaf842e66 100644 --- a/modules/@angular/core/test/linker/ng_module_integration_spec.ts +++ b/modules/@angular/core/test/linker/ng_module_integration_spec.ts @@ -11,9 +11,9 @@ import {Console} from '@angular/core/src/console'; import {ComponentFixture, TestBed, inject} from '@angular/core/testing'; import {expect} from '@angular/platform-browser/testing/matchers'; -import {stringify} from '../../src/facade/lang'; import {NgModuleInjector} from '../../src/linker/ng_module_factory'; import {clearModulesForTest} from '../../src/linker/ng_module_factory_loader'; +import {stringify} from '../../src/util'; class Engine {} diff --git a/modules/@angular/core/test/linker/query_integration_spec.ts b/modules/@angular/core/test/linker/query_integration_spec.ts index fd81f080a7..06e76e6da3 100644 --- a/modules/@angular/core/test/linker/query_integration_spec.ts +++ b/modules/@angular/core/test/linker/query_integration_spec.ts @@ -10,7 +10,7 @@ import {AfterContentChecked, AfterContentInit, AfterViewChecked, AfterViewInit, import {ComponentFixture, TestBed, async} from '@angular/core/testing'; import {expect} from '@angular/platform-browser/testing/matchers'; -import {stringify} from '../../src/facade/lang'; +import {stringify} from '../../src/util'; export function main() { describe('Query API', () => { diff --git a/modules/@angular/core/test/zone/ng_zone_spec.ts b/modules/@angular/core/test/zone/ng_zone_spec.ts index 0ec55af5b7..010857087b 100644 --- a/modules/@angular/core/test/zone/ng_zone_spec.ts +++ b/modules/@angular/core/test/zone/ng_zone_spec.ts @@ -10,7 +10,6 @@ import {NgZone} from '@angular/core/src/zone/ng_zone'; import {async, fakeAsync, flushMicrotasks} from '@angular/core/testing'; import {AsyncTestCompleter, Log, beforeEach, describe, expect, inject, it, xit} from '@angular/core/testing/testing_internal'; import {browserDetection} from '@angular/platform-browser/testing/browser_util'; -import {isPresent} from '../../src/facade/lang'; import {scheduleMicroTask} from '../../src/util'; const needsLongerTimers = browserDetection.isSlow || browserDetection.isEdge; @@ -159,7 +158,7 @@ export function main() { promise.then((_) => { expect(_traces.length).toBe(1); - if (isPresent(_traces[0])) { + if (_traces[0] != null) { // some browsers don't have stack traces. expect(_traces[0].indexOf('---')).toEqual(-1); } diff --git a/modules/@angular/core/testing/facade b/modules/@angular/core/testing/facade deleted file mode 120000 index e084c803c6..0000000000 --- a/modules/@angular/core/testing/facade +++ /dev/null @@ -1 +0,0 @@ -../../facade/src \ No newline at end of file diff --git a/modules/@angular/core/testing/test_bed.ts b/modules/@angular/core/testing/test_bed.ts index b43c95d7ef..07a87fedb1 100644 --- a/modules/@angular/core/testing/test_bed.ts +++ b/modules/@angular/core/testing/test_bed.ts @@ -6,10 +6,9 @@ * found in the LICENSE file at https://angular.io/license */ -import {CompilerOptions, Component, Directive, InjectionToken, Injector, ModuleWithComponentFactories, NgModule, NgModuleRef, NgZone, Pipe, PlatformRef, Provider, ReflectiveInjector, SchemaMetadata, Type, ɵERROR_COMPONENT_TYPE} from '@angular/core'; +import {CompilerOptions, Component, Directive, InjectionToken, Injector, ModuleWithComponentFactories, NgModule, NgModuleRef, NgZone, Pipe, PlatformRef, Provider, ReflectiveInjector, SchemaMetadata, Type, ɵERROR_COMPONENT_TYPE, ɵstringify as stringify} from '@angular/core'; import {AsyncTestCompleter} from './async_test_completer'; import {ComponentFixture} from './component_fixture'; -import {stringify} from './facade/lang'; import {MetadataOverride} from './metadata_override'; import {TestingCompiler, TestingCompilerFactory} from './test_compiler'; diff --git a/modules/@angular/examples/facade/ts/async/observable.ts b/modules/@angular/examples/facade/ts/async/observable.ts deleted file mode 100644 index 739e8d372a..0000000000 --- a/modules/@angular/examples/facade/ts/async/observable.ts +++ /dev/null @@ -1,19 +0,0 @@ -/** - * @license - * Copyright Google Inc. All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ - -/* tslint:disable:no-console */ -// #docregion Observable -import {Observable} from 'rxjs/Observable'; -import {Subscriber} from 'rxjs/Subscriber'; - -const obs = new Observable((obs: Subscriber) => { - let i = 0; - setInterval(() => { obs.next(++i); }, 1000); -}); -obs.subscribe(i => console.log(`${i} seconds elapsed`)); -// #enddocregion diff --git a/modules/@angular/examples/facade/ts/async/observable_patched.ts b/modules/@angular/examples/facade/ts/async/observable_patched.ts deleted file mode 100644 index 0dbde026d3..0000000000 --- a/modules/@angular/examples/facade/ts/async/observable_patched.ts +++ /dev/null @@ -1,21 +0,0 @@ -/** - * @license - * Copyright Google Inc. All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ - -/* tslint:disable:no-console */ -// #docregion Observable -import 'rxjs/add/operator/map'; - -import {Observable} from 'rxjs/Observable'; -import {Subscriber} from 'rxjs/Subscriber'; - -const obs = new Observable((obs: Subscriber) => { - let i = 0; - setInterval(() => obs.next(++i), 1000); -}); -obs.map((i: number) => `${i} seconds elapsed`).subscribe(msg => console.log(msg)); -// #enddocregion diff --git a/modules/@angular/examples/facade/ts/async/observable_pure.ts b/modules/@angular/examples/facade/ts/async/observable_pure.ts deleted file mode 100644 index 3028464088..0000000000 --- a/modules/@angular/examples/facade/ts/async/observable_pure.ts +++ /dev/null @@ -1,20 +0,0 @@ -/** - * @license - * Copyright Google Inc. All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ - -/* tslint:disable:no-console */ -// #docregion Observable -import {Observable} from 'rxjs/Observable'; -import {Subscriber} from 'rxjs/Subscriber'; -import {map} from 'rxjs/operator/map'; - -const obs = new Observable((sub: Subscriber) => { - let i = 0; - setInterval(() => sub.next(++i), 1000); -}); -map.call(obs, (i: number) => `${i} seconds elapsed`).subscribe((msg: string) => console.log(msg)); -// #enddocregion diff --git a/modules/@angular/facade/src/lang.ts b/modules/@angular/facade/src/lang.ts deleted file mode 100644 index b0b0400d07..0000000000 --- a/modules/@angular/facade/src/lang.ts +++ /dev/null @@ -1,102 +0,0 @@ -/** - * @license - * Copyright Google Inc. All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ - - -export function getTypeNameForDebugging(type: any): string { - return type['name'] || typeof type; -} - -export function isPresent(obj: any): boolean { - return obj != null; -} - -export function isBlank(obj: any): boolean { - return obj == null; -} - -const STRING_MAP_PROTO = Object.getPrototypeOf({}); -export function isStrictStringMap(obj: any): boolean { - return typeof obj === 'object' && obj !== null && Object.getPrototypeOf(obj) === STRING_MAP_PROTO; -} - -export function stringify(token: any): string { - if (typeof token === 'string') { - return token; - } - - if (token == null) { - return '' + token; - } - - if (token.overriddenName) { - return `${token.overriddenName}`; - } - - if (token.name) { - return `${token.name}`; - } - - const res = token.toString(); - const newLineIndex = res.indexOf('\n'); - return newLineIndex === -1 ? res : res.substring(0, newLineIndex); -} - -export class NumberWrapper { - static parseIntAutoRadix(text: string): number { - const result: number = parseInt(text); - if (isNaN(result)) { - throw new Error('Invalid integer literal when parsing ' + text); - } - return result; - } - - static isNumeric(value: any): boolean { return !isNaN(value - parseFloat(value)); } -} - -// JS has NaN !== NaN -export function looseIdentical(a: any, b: any): boolean { - return a === b || typeof a === 'number' && typeof b === 'number' && isNaN(a) && isNaN(b); -} - -export function isJsObject(o: any): boolean { - return o !== null && (typeof o === 'function' || typeof o === 'object'); -} - -export function print(obj: Error | Object) { - // tslint:disable-next-line:no-console - console.log(obj); -} - -export function warn(obj: Error | Object) { - console.warn(obj); -} - -export function setValueOnPath(global: any, path: string, value: any) { - const parts = path.split('.'); - let obj: any = global; - while (parts.length > 1) { - const name = parts.shift(); - if (obj.hasOwnProperty(name) && obj[name] != null) { - obj = obj[name]; - } else { - obj = obj[name] = {}; - } - } - if (obj === undefined || obj === null) { - obj = {}; - } - obj[parts.shift()] = value; -} - -export function isPrimitive(obj: any): boolean { - return !isJsObject(obj); -} - -export function escapeRegExp(s: string): string { - return s.replace(/([.*+?^=!:${}()|[\]\/\\])/g, '\\$1'); -} diff --git a/modules/@angular/facade/test/lang_spec.ts b/modules/@angular/facade/test/lang_spec.ts deleted file mode 100644 index 3eb0a5d920..0000000000 --- a/modules/@angular/facade/test/lang_spec.ts +++ /dev/null @@ -1,43 +0,0 @@ -/** - * @license - * Copyright Google Inc. All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ - -import {NumberWrapper, escapeRegExp} from '../src/lang'; - -export function main() { - describe('RegExp', () => { - it('should escape regexp', () => { - expect(new RegExp(escapeRegExp('b')).exec('abc')).toBeTruthy(); - expect(new RegExp(escapeRegExp('b')).exec('adc')).toBeFalsy(); - expect(new RegExp(escapeRegExp('a.b')).exec('a.b')).toBeTruthy(); - expect(new RegExp(escapeRegExp('a.b')).exec('axb')).toBeFalsy(); - }); - - }); - - describe('Number', () => { - describe('isNumeric', () => { - it('should return true when passing correct numeric string', - () => { expect(NumberWrapper.isNumeric('2')).toBe(true); }); - - it('should return true when passing correct double string', - () => { expect(NumberWrapper.isNumeric('1.123')).toBe(true); }); - - it('should return true when passing correct negative string', - () => { expect(NumberWrapper.isNumeric('-2')).toBe(true); }); - - it('should return true when passing correct scientific notation string', - () => { expect(NumberWrapper.isNumeric('1e5')).toBe(true); }); - - it('should return false when passing incorrect numeric', - () => { expect(NumberWrapper.isNumeric('a')).toBe(false); }); - - it('should return false when passing parseable but non numeric', - () => { expect(NumberWrapper.isNumeric('2a')).toBe(false); }); - }); - }); -} diff --git a/modules/@angular/forms/src/directives/select_control_value_accessor.ts b/modules/@angular/forms/src/directives/select_control_value_accessor.ts index f8423ff8d5..daf5d03727 100644 --- a/modules/@angular/forms/src/directives/select_control_value_accessor.ts +++ b/modules/@angular/forms/src/directives/select_control_value_accessor.ts @@ -6,10 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -import {Directive, ElementRef, Host, Input, OnDestroy, Optional, Provider, Renderer, forwardRef} from '@angular/core'; - -import {isPrimitive, looseIdentical} from '../facade/lang'; - +import {Directive, ElementRef, Host, Input, OnDestroy, Optional, Provider, Renderer, forwardRef, ɵlooseIdentical as looseIdentical} from '@angular/core'; import {ControlValueAccessor, NG_VALUE_ACCESSOR} from './control_value_accessor'; export const SELECT_VALUE_ACCESSOR: Provider = { @@ -20,7 +17,7 @@ export const SELECT_VALUE_ACCESSOR: Provider = { function _buildValueString(id: string, value: any): string { if (id == null) return `${value}`; - if (!isPrimitive(value)) value = 'Object'; + if (value && typeof value === 'object') value = 'Object'; return `${id}: ${value}`.slice(0, 50); } diff --git a/modules/@angular/forms/src/directives/select_multiple_control_value_accessor.ts b/modules/@angular/forms/src/directives/select_multiple_control_value_accessor.ts index 72639a39b9..960cea7a64 100644 --- a/modules/@angular/forms/src/directives/select_multiple_control_value_accessor.ts +++ b/modules/@angular/forms/src/directives/select_multiple_control_value_accessor.ts @@ -6,10 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -import {Directive, ElementRef, Host, Input, OnDestroy, Optional, Provider, Renderer, forwardRef} from '@angular/core'; - -import {isPrimitive, looseIdentical} from '../facade/lang'; - +import {Directive, ElementRef, Host, Input, OnDestroy, Optional, Provider, Renderer, forwardRef, ɵlooseIdentical as looseIdentical} from '@angular/core'; import {ControlValueAccessor, NG_VALUE_ACCESSOR} from './control_value_accessor'; export const SELECT_MULTIPLE_VALUE_ACCESSOR: Provider = { @@ -21,7 +18,7 @@ export const SELECT_MULTIPLE_VALUE_ACCESSOR: Provider = { function _buildValueString(id: string, value: any): string { if (id == null) return `${value}`; if (typeof value === 'string') value = `'${value}'`; - if (!isPrimitive(value)) value = 'Object'; + if (value && typeof value === 'object') value = 'Object'; return `${id}: ${value}`.slice(0, 50); } diff --git a/modules/@angular/forms/src/directives/shared.ts b/modules/@angular/forms/src/directives/shared.ts index 6a0d397d98..c8342bd334 100644 --- a/modules/@angular/forms/src/directives/shared.ts +++ b/modules/@angular/forms/src/directives/shared.ts @@ -6,10 +6,9 @@ * found in the LICENSE file at https://angular.io/license */ -import {isBlank, isPresent, looseIdentical} from '../facade/lang'; +import {ɵlooseIdentical as looseIdentical} from '@angular/core'; import {FormArray, FormControl, FormGroup} from '../model'; import {Validators} from '../validators'; - import {AbstractControlDirective} from './abstract_control_directive'; import {AbstractFormGroupDirective} from './abstract_form_group_directive'; import {CheckboxControlValueAccessor} from './checkbox_value_accessor'; @@ -95,7 +94,7 @@ export function cleanUpControl(control: FormControl, dir: NgControl) { export function setUpFormContainer( control: FormGroup | FormArray, dir: AbstractFormGroupDirective | FormArrayName) { - if (isBlank(control)) _throwError(dir, 'Cannot find control with'); + if (control == null) _throwError(dir, 'Cannot find control with'); control.validator = Validators.compose([control.validator, dir.validator]); control.asyncValidator = Validators.composeAsync([control.asyncValidator, dir.asyncValidator]); } @@ -117,12 +116,12 @@ function _throwError(dir: AbstractControlDirective, message: string): void { } export function composeValidators(validators: Array): ValidatorFn { - return isPresent(validators) ? Validators.compose(validators.map(normalizeValidator)) : null; + return validators != null ? Validators.compose(validators.map(normalizeValidator)) : null; } export function composeAsyncValidators(validators: Array): AsyncValidatorFn { - return isPresent(validators) ? Validators.composeAsync(validators.map(normalizeAsyncValidator)) : - null; + return validators != null ? Validators.composeAsync(validators.map(normalizeAsyncValidator)) : + null; } export function isPropertyUpdated(changes: {[key: string]: any}, viewModel: any): boolean { diff --git a/modules/@angular/forms/src/facade b/modules/@angular/forms/src/facade deleted file mode 120000 index e084c803c6..0000000000 --- a/modules/@angular/forms/src/facade +++ /dev/null @@ -1 +0,0 @@ -../../facade/src \ No newline at end of file diff --git a/modules/@angular/forms/src/form_builder.ts b/modules/@angular/forms/src/form_builder.ts index 6dc924387d..1384ea1d38 100644 --- a/modules/@angular/forms/src/form_builder.ts +++ b/modules/@angular/forms/src/form_builder.ts @@ -9,7 +9,6 @@ import {Injectable} from '@angular/core'; import {AsyncValidatorFn, ValidatorFn} from './directives/validators'; -import {isPresent} from './facade/lang'; import {AbstractControl, FormArray, FormControl, FormGroup} from './model'; /** @@ -42,8 +41,8 @@ export class FormBuilder { */ group(controlsConfig: {[key: string]: any}, extra: {[key: string]: any} = null): FormGroup { const controls = this._reduceControls(controlsConfig); - const validator: ValidatorFn = isPresent(extra) ? extra['validator'] : null; - const asyncValidator: AsyncValidatorFn = isPresent(extra) ? extra['asyncValidator'] : null; + const validator: ValidatorFn = extra != null ? extra['validator'] : null; + const asyncValidator: AsyncValidatorFn = extra != null ? extra['asyncValidator'] : null; return new FormGroup(controls, validator, asyncValidator); } /** diff --git a/modules/@angular/forms/src/validators.ts b/modules/@angular/forms/src/validators.ts index dbb4e33d54..595be10e90 100644 --- a/modules/@angular/forms/src/validators.ts +++ b/modules/@angular/forms/src/validators.ts @@ -9,7 +9,6 @@ import {InjectionToken, ɵisPromise as isPromise, ɵmerge as merge} from '@angular/core'; import {toPromise} from 'rxjs/operator/toPromise'; import {AsyncValidatorFn, Validator, ValidatorFn} from './directives/validators'; -import {isPresent} from './facade/lang'; import {AbstractControl, FormControl, FormGroup} from './model'; function isEmptyInputValue(value: any): boolean { @@ -187,6 +186,10 @@ export class Validators { } } +function isPresent(o: any): boolean { + return o != null; +} + function _convertToPromise(obj: any): Promise { return isPromise(obj) ? obj : toPromise.call(obj); } @@ -202,7 +205,7 @@ function _executeAsyncValidators(control: AbstractControl, validators: AsyncVali function _mergeErrors(arrayOfErrors: any[]): {[key: string]: any} { const res: {[key: string]: any} = arrayOfErrors.reduce((res: {[key: string]: any}, errors: {[key: string]: any}) => { - return isPresent(errors) ? merge(res, errors) : res; + return errors != null ? merge(res, errors) : res; }, {}); return Object.keys(res).length === 0 ? null : res; } diff --git a/modules/@angular/forms/test/form_array_spec.ts b/modules/@angular/forms/test/form_array_spec.ts index dfa1c2ea63..717afacd6d 100644 --- a/modules/@angular/forms/test/form_array_spec.ts +++ b/modules/@angular/forms/test/form_array_spec.ts @@ -10,7 +10,6 @@ import {fakeAsync, tick} from '@angular/core/testing'; import {AsyncTestCompleter, beforeEach, describe, inject, it} from '@angular/core/testing/testing_internal'; import {AbstractControl, FormArray, FormControl, FormGroup} from '@angular/forms'; -import {isPresent} from '../src/facade/lang'; import {Validators} from '../src/validators'; export function main() { @@ -18,7 +17,7 @@ export function main() { return (c: AbstractControl) => { let resolve: (result: any) => void; const promise = new Promise(res => { resolve = res; }); - const t = isPresent((timeouts as any)[c.value]) ? (timeouts as any)[c.value] : 0; + const t = (timeouts as any)[c.value] != null ? (timeouts as any)[c.value] : 0; const res = c.value != expected ? {'async': true} : null; if (t == 0) { diff --git a/modules/@angular/forms/test/form_control_spec.ts b/modules/@angular/forms/test/form_control_spec.ts index a6edc3114a..11089c3e5b 100644 --- a/modules/@angular/forms/test/form_control_spec.ts +++ b/modules/@angular/forms/test/form_control_spec.ts @@ -11,7 +11,6 @@ import {fakeAsync, tick} from '@angular/core/testing'; import {AsyncTestCompleter, beforeEach, describe, inject, it} from '@angular/core/testing/testing_internal'; import {FormControl, FormGroup, Validators} from '@angular/forms'; -import {isPresent} from '../src/facade/lang'; import {FormArray} from '../src/model'; export function main() { @@ -19,7 +18,7 @@ export function main() { return (c: FormControl) => { let resolve: (result: any) => void; const promise = new Promise(res => { resolve = res; }); - const t = isPresent((timeouts as any)[c.value]) ? (timeouts as any)[c.value] : 0; + const t = (timeouts as any)[c.value] != null ? (timeouts as any)[c.value] : 0; const res = c.value != expected ? {'async': true} : null; if (t == 0) { diff --git a/modules/@angular/forms/test/form_group_spec.ts b/modules/@angular/forms/test/form_group_spec.ts index e37b735ccc..56f52f9dd5 100644 --- a/modules/@angular/forms/test/form_group_spec.ts +++ b/modules/@angular/forms/test/form_group_spec.ts @@ -11,14 +11,13 @@ import {async, fakeAsync, tick} from '@angular/core/testing'; import {AsyncTestCompleter, beforeEach, describe, inject, it} from '@angular/core/testing/testing_internal'; import {AbstractControl, FormArray, FormControl, FormGroup, Validators} from '@angular/forms'; -import {isPresent} from '../src/facade/lang'; export function main() { function asyncValidator(expected: string, timeouts = {}) { return (c: AbstractControl) => { let resolve: (result: any) => void; const promise = new Promise(res => { resolve = res; }); - const t = isPresent((timeouts as any)[c.value]) ? (timeouts as any)[c.value] : 0; + const t = (timeouts as any)[c.value] != null ? (timeouts as any)[c.value] : 0; const res = c.value != expected ? {'async': true} : null; if (t == 0) { diff --git a/modules/@angular/platform-browser-dynamic/src/facade b/modules/@angular/platform-browser-dynamic/src/facade deleted file mode 120000 index e084c803c6..0000000000 --- a/modules/@angular/platform-browser-dynamic/src/facade +++ /dev/null @@ -1 +0,0 @@ -../../facade/src \ No newline at end of file diff --git a/modules/@angular/platform-browser-dynamic/src/resource_loader/resource_loader_impl.ts b/modules/@angular/platform-browser-dynamic/src/resource_loader/resource_loader_impl.ts index 9cca515488..b047058b69 100644 --- a/modules/@angular/platform-browser-dynamic/src/resource_loader/resource_loader_impl.ts +++ b/modules/@angular/platform-browser-dynamic/src/resource_loader/resource_loader_impl.ts @@ -8,7 +8,6 @@ import {ResourceLoader} from '@angular/compiler'; import {Injectable} from '@angular/core'; -import {isPresent} from '../facade/lang'; @Injectable() export class ResourceLoaderImpl extends ResourceLoader { diff --git a/modules/@angular/platform-browser-dynamic/testing/facade b/modules/@angular/platform-browser-dynamic/testing/facade deleted file mode 120000 index e084c803c6..0000000000 --- a/modules/@angular/platform-browser-dynamic/testing/facade +++ /dev/null @@ -1 +0,0 @@ -../../facade/src \ No newline at end of file diff --git a/modules/@angular/platform-browser/src/browser/browser_adapter.ts b/modules/@angular/platform-browser/src/browser/browser_adapter.ts index e5288b3fb8..f1c8f3e27b 100644 --- a/modules/@angular/platform-browser/src/browser/browser_adapter.ts +++ b/modules/@angular/platform-browser/src/browser/browser_adapter.ts @@ -8,7 +8,6 @@ import {ɵglobal as global} from '@angular/core'; import {setRootDomAdapter} from '../dom/dom_adapter'; -import {isBlank, isPresent, setValueOnPath} from '../facade/lang'; import {GenericBrowserDomAdapter} from './generic_browser_adapter'; @@ -133,7 +132,7 @@ export class BrowserDomAdapter extends GenericBrowserDomAdapter { evt.returnValue = false; } isPrevented(evt: Event): boolean { - return evt.defaultPrevented || isPresent(evt.returnValue) && !evt.returnValue; + return evt.defaultPrevented || evt.returnValue != null && !evt.returnValue; } getInnerHTML(el: HTMLElement): string { return el.innerHTML; } getTemplateContent(el: Node): Node { @@ -297,7 +296,7 @@ export class BrowserDomAdapter extends GenericBrowserDomAdapter { isCommentNode(node: Node): boolean { return node.nodeType === Node.COMMENT_NODE; } isElementNode(node: Node): boolean { return node.nodeType === Node.ELEMENT_NODE; } hasShadowRoot(node: any): boolean { - return isPresent(node.shadowRoot) && node instanceof HTMLElement; + return node.shadowRoot != null && node instanceof HTMLElement; } isShadowRoot(node: any): boolean { return node instanceof DocumentFragment; } importIntoDoc(node: Node): any { return document.importNode(this.templateAwareRoot(node), true); } @@ -306,12 +305,12 @@ export class BrowserDomAdapter extends GenericBrowserDomAdapter { getEventKey(event: any): string { let key = event.key; - if (isBlank(key)) { + if (key == null) { key = event.keyIdentifier; // keyIdentifier is defined in the old draft of DOM Level 3 Events implemented by Chrome and // Safari cf // http://www.w3.org/TR/2007/WD-DOM-Level-3-Events-20071221/events.html#Events-KeyboardEvents-Interfaces - if (isBlank(key)) { + if (key == null) { return 'Unidentified'; } if (key.startsWith('U+')) { @@ -342,7 +341,7 @@ export class BrowserDomAdapter extends GenericBrowserDomAdapter { getLocation(): Location { return window.location; } getBaseHref(doc: Document): string { const href = getBaseElementHref(); - return isBlank(href) ? null : relativePath(href); + return href == null ? null : relativePath(href); } resetBaseElement(): void { baseElement = null; } getUserAgent(): string { return window.navigator.userAgent; } @@ -410,3 +409,20 @@ export function parseCookieValue(cookieStr: string, name: string): string { } return null; } + +export function setValueOnPath(global: any, path: string, value: any) { + const parts = path.split('.'); + let obj: any = global; + while (parts.length > 1) { + const name = parts.shift(); + if (obj.hasOwnProperty(name) && obj[name] != null) { + obj = obj[name]; + } else { + obj = obj[name] = {}; + } + } + if (obj === undefined || obj === null) { + obj = {}; + } + obj[parts.shift()] = value; +} diff --git a/modules/@angular/platform-browser/src/browser/generic_browser_adapter.ts b/modules/@angular/platform-browser/src/browser/generic_browser_adapter.ts index f2b5776e30..f3da271527 100644 --- a/modules/@angular/platform-browser/src/browser/generic_browser_adapter.ts +++ b/modules/@angular/platform-browser/src/browser/generic_browser_adapter.ts @@ -7,7 +7,6 @@ */ import {DomAdapter} from '../dom/dom_adapter'; -import {isPresent} from '../facade/lang'; @@ -24,13 +23,13 @@ export abstract class GenericBrowserDomAdapter extends DomAdapter { super(); try { const element = this.createElement('div', document); - if (isPresent(this.getStyle(element, 'animationName'))) { + if (this.getStyle(element, 'animationName') != null) { this._animationPrefix = ''; } else { const domPrefixes = ['Webkit', 'Moz', 'O', 'ms']; for (let i = 0; i < domPrefixes.length; i++) { - if (isPresent(this.getStyle(element, domPrefixes[i] + 'AnimationName'))) { + if (this.getStyle(element, domPrefixes[i] + 'AnimationName') != null) { this._animationPrefix = '-' + domPrefixes[i].toLowerCase() + '-'; break; } @@ -45,7 +44,7 @@ export abstract class GenericBrowserDomAdapter extends DomAdapter { }; Object.keys(transEndEventNames).forEach((key: string) => { - if (isPresent(this.getStyle(element, key))) { + if (this.getStyle(element, key) != null) { this._transitionEnd = transEndEventNames[key]; } }); @@ -66,6 +65,6 @@ export abstract class GenericBrowserDomAdapter extends DomAdapter { getAnimationPrefix(): string { return this._animationPrefix ? this._animationPrefix : ''; } getTransitionEnd(): string { return this._transitionEnd ? this._transitionEnd : ''; } supportsAnimation(): boolean { - return isPresent(this._animationPrefix) && isPresent(this._transitionEnd); + return this._animationPrefix != null && this._transitionEnd != null; } } diff --git a/modules/@angular/platform-browser/src/browser/testability.ts b/modules/@angular/platform-browser/src/browser/testability.ts index a415bd8501..369e4369ba 100644 --- a/modules/@angular/platform-browser/src/browser/testability.ts +++ b/modules/@angular/platform-browser/src/browser/testability.ts @@ -9,7 +9,6 @@ import {GetTestability, Testability, TestabilityRegistry, setTestabilityGetter, ɵglobal as global} from '@angular/core'; import {getDOM} from '../dom/dom_adapter'; -import {isPresent} from '../facade/lang'; export class BrowserGetTestability implements GetTestability { static init() { setTestabilityGetter(new BrowserGetTestability()); } @@ -55,7 +54,7 @@ export class BrowserGetTestability implements GetTestability { return null; } const t = registry.getTestability(elem); - if (isPresent(t)) { + if (t != null) { return t; } else if (!findInAncestors) { return null; diff --git a/modules/@angular/examples/facade/ts/async/observable_all.ts b/modules/@angular/platform-browser/src/browser/tools/browser.ts similarity index 69% rename from modules/@angular/examples/facade/ts/async/observable_all.ts rename to modules/@angular/platform-browser/src/browser/tools/browser.ts index b7df477675..2f233c4700 100644 --- a/modules/@angular/examples/facade/ts/async/observable_all.ts +++ b/modules/@angular/platform-browser/src/browser/tools/browser.ts @@ -6,6 +6,5 @@ * found in the LICENSE file at https://angular.io/license */ -// #docregion Observable -import 'rxjs'; -// #enddocregion +const win = typeof window !== 'undefined' && window || {}; +export {win as window}; diff --git a/modules/@angular/platform-browser/src/browser/tools/common_tools.ts b/modules/@angular/platform-browser/src/browser/tools/common_tools.ts index 1d184bb9a0..f4f7d05894 100644 --- a/modules/@angular/platform-browser/src/browser/tools/common_tools.ts +++ b/modules/@angular/platform-browser/src/browser/tools/common_tools.ts @@ -7,11 +7,8 @@ */ import {ApplicationRef, ComponentRef} from '@angular/core'; - import {getDOM} from '../../dom/dom_adapter'; -import {isPresent} from '../../facade/lang'; - -const win = typeof window !== 'undefined' && window || {}; +import {window} from './browser'; export class ChangeDetectionPerfRecord { constructor(public msPerTick: number, public numTicks: number) {} @@ -47,9 +44,9 @@ export class AngularProfiler { const record = config && config['record']; const profileName = 'Change Detection'; // Profiler is not available in Android browsers, nor in IE 9 without dev tools opened - const isProfilerAvailable = isPresent(win.console.profile); + const isProfilerAvailable = window.console.profile != null; if (record && isProfilerAvailable) { - win.console.profile(profileName); + window.console.profile(profileName); } const start = getDOM().performanceNow(); let numTicks = 0; @@ -63,11 +60,11 @@ export class AngularProfiler { // while in fact there is: // // https://developer.mozilla.org/en-US/docs/Web/API/Console/profileEnd - (win.console.profileEnd)(profileName); + (window.console.profileEnd)(profileName); } const msPerTick = (end - start) / numTicks; - win.console.log(`ran ${numTicks} change detection cycles`); - win.console.log(`${msPerTick.toFixed(2)} ms per check`); + window.console.log(`ran ${numTicks} change detection cycles`); + window.console.log(`${msPerTick.toFixed(2)} ms per check`); return new ChangeDetectionPerfRecord(msPerTick, numTicks); } diff --git a/modules/@angular/platform-browser/src/dom/debug/by.ts b/modules/@angular/platform-browser/src/dom/debug/by.ts index 0f5903a192..3d2096e88c 100644 --- a/modules/@angular/platform-browser/src/dom/debug/by.ts +++ b/modules/@angular/platform-browser/src/dom/debug/by.ts @@ -8,7 +8,6 @@ import {DebugElement, Predicate, Type} from '@angular/core'; import {getDOM} from '../../dom/dom_adapter'; -import {isPresent} from '../../facade/lang'; @@ -36,7 +35,7 @@ export class By { */ static css(selector: string): Predicate { return (debugElement) => { - return isPresent(debugElement.nativeElement) ? + return debugElement.nativeElement != null ? getDOM().elementMatches(debugElement.nativeElement, selector) : false; }; diff --git a/modules/@angular/platform-browser/src/dom/dom_renderer.ts b/modules/@angular/platform-browser/src/dom/dom_renderer.ts index 57b994db3d..814df0df54 100644 --- a/modules/@angular/platform-browser/src/dom/dom_renderer.ts +++ b/modules/@angular/platform-browser/src/dom/dom_renderer.ts @@ -7,10 +7,6 @@ */ import {APP_ID, Inject, Injectable, RenderComponentType, Renderer, RendererFactoryV2, RendererTypeV2, RendererV2, RootRenderer, ViewEncapsulation} from '@angular/core'; - -import {isPresent, stringify} from '../facade/lang'; - -import {DOCUMENT} from './dom_tokens'; import {EventManager} from './events/event_manager'; import {DomSharedStylesHost} from './shared_styles_host'; diff --git a/modules/@angular/platform-browser/src/facade b/modules/@angular/platform-browser/src/facade deleted file mode 120000 index e084c803c6..0000000000 --- a/modules/@angular/platform-browser/src/facade +++ /dev/null @@ -1 +0,0 @@ -../../facade/src \ No newline at end of file diff --git a/modules/@angular/platform-browser/src/private_export.ts b/modules/@angular/platform-browser/src/private_export.ts index 6423400cd5..ebe72dcf42 100644 --- a/modules/@angular/platform-browser/src/private_export.ts +++ b/modules/@angular/platform-browser/src/private_export.ts @@ -8,6 +8,7 @@ export {BROWSER_SANITIZATION_PROVIDERS as ɵBROWSER_SANITIZATION_PROVIDERS, INTERNAL_BROWSER_PLATFORM_PROVIDERS as ɵINTERNAL_BROWSER_PLATFORM_PROVIDERS, initDomAdapter as ɵinitDomAdapter} from './browser'; export {BrowserDomAdapter as ɵBrowserDomAdapter} from './browser/browser_adapter'; +export {setValueOnPath as ɵsetValueOnPath} from './browser/browser_adapter'; export {BrowserPlatformLocation as ɵBrowserPlatformLocation} from './browser/location/browser_platform_location'; export {TRANSITION_ID as ɵTRANSITION_ID} from './browser/server-transition'; export {BrowserGetTestability as ɵBrowserGetTestability} from './browser/testability'; diff --git a/modules/@angular/platform-browser/test/browser/bootstrap_spec.ts b/modules/@angular/platform-browser/test/browser/bootstrap_spec.ts index 7a997508ab..3adc9a6329 100644 --- a/modules/@angular/platform-browser/test/browser/bootstrap_spec.ts +++ b/modules/@angular/platform-browser/test/browser/bootstrap_spec.ts @@ -7,7 +7,7 @@ */ import {isPlatformBrowser} from '@angular/common'; -import {APP_INITIALIZER, CUSTOM_ELEMENTS_SCHEMA, Compiler, Component, Directive, ErrorHandler, Inject, Input, LOCALE_ID, NgModule, OnDestroy, PLATFORM_ID, PLATFORM_INITIALIZER, Pipe, Provider, VERSION, createPlatformFactory} from '@angular/core'; +import {APP_INITIALIZER, CUSTOM_ELEMENTS_SCHEMA, Compiler, Component, Directive, ErrorHandler, Inject, Input, LOCALE_ID, NgModule, OnDestroy, PLATFORM_ID, PLATFORM_INITIALIZER, Pipe, Provider, VERSION, createPlatformFactory, ɵstringify as stringify} from '@angular/core'; import {ApplicationRef, destroyPlatform} from '@angular/core/src/application_ref'; import {Console} from '@angular/core/src/console'; import {ComponentRef} from '@angular/core/src/linker/component_factory'; @@ -19,8 +19,6 @@ import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter'; import {DOCUMENT} from '@angular/platform-browser/src/dom/dom_tokens'; import {expect} from '@angular/platform-browser/testing/matchers'; -import {stringify} from '../../src/facade/lang'; - @Component({selector: 'non-existent', template: ''}) class NonExistentComp { } diff --git a/modules/@angular/platform-browser/test/testing_public_spec.ts b/modules/@angular/platform-browser/test/testing_public_spec.ts index a68cd66064..ae45b33ae3 100644 --- a/modules/@angular/platform-browser/test/testing_public_spec.ts +++ b/modules/@angular/platform-browser/test/testing_public_spec.ts @@ -7,12 +7,10 @@ */ import {CompilerConfig, ResourceLoader} from '@angular/compiler'; -import {CUSTOM_ELEMENTS_SCHEMA, Component, Directive, Injectable, Input, NgModule, Pipe} from '@angular/core'; +import {CUSTOM_ELEMENTS_SCHEMA, Component, Directive, Injectable, Input, NgModule, Pipe, ɵstringify as stringify} from '@angular/core'; import {TestBed, async, fakeAsync, getTestBed, inject, tick, withModule} from '@angular/core/testing'; import {expect} from '@angular/platform-browser/testing/matchers'; -import {stringify} from '../src/facade/lang'; - // Services, and components for the tests. @Component({selector: 'child-comp', template: `Original {{childBinding}}`}) diff --git a/modules/@angular/platform-browser/testing/facade b/modules/@angular/platform-browser/testing/facade deleted file mode 120000 index e084c803c6..0000000000 --- a/modules/@angular/platform-browser/testing/facade +++ /dev/null @@ -1 +0,0 @@ -../../facade/src \ No newline at end of file diff --git a/modules/@angular/platform-server/src/facade b/modules/@angular/platform-server/src/facade deleted file mode 120000 index e084c803c6..0000000000 --- a/modules/@angular/platform-server/src/facade +++ /dev/null @@ -1 +0,0 @@ -../../facade/src \ No newline at end of file diff --git a/modules/@angular/platform-server/src/parse5_adapter.ts b/modules/@angular/platform-server/src/parse5_adapter.ts index aa52853912..a612086404 100644 --- a/modules/@angular/platform-server/src/parse5_adapter.ts +++ b/modules/@angular/platform-server/src/parse5_adapter.ts @@ -9,8 +9,7 @@ const parse5 = require('parse5'); import {ɵglobal as global} from '@angular/core'; -import {ɵDomAdapter as DomAdapter, ɵsetRootDomAdapter as setRootDomAdapter} from '@angular/platform-browser'; -import {isPresent, isBlank, setValueOnPath} from '../src/facade/lang'; +import {ɵDomAdapter as DomAdapter, ɵsetRootDomAdapter as setRootDomAdapter, ɵsetValueOnPath as setValueOnPath} from '@angular/platform-browser'; import {SelectorMatcher, CssSelector} from '@angular/compiler'; let treeAdapter: any; @@ -172,7 +171,7 @@ export class Parse5DomAdapter extends DomAdapter { return event; } preventDefault(event: any) { event.returnValue = false; } - isPrevented(event: any): boolean { return isPresent(event.returnValue) && !event.returnValue; } + isPrevented(event: any): boolean { return event.returnValue != null && !event.returnValue; } getInnerHTML(el: any): string { return parse5.serialize(this.templateAwareRoot(el), {treeAdapter}); } @@ -340,7 +339,7 @@ export class Parse5DomAdapter extends DomAdapter { nodeClone.children = null; mapProps.forEach(mapName => { - if (isPresent(node[mapName])) { + if (node[mapName] != null) { nodeClone[mapName] = {}; for (const prop in node[mapName]) { nodeClone[mapName][prop] = node[mapName][prop]; @@ -500,7 +499,7 @@ export class Parse5DomAdapter extends DomAdapter { isTextNode(node: any): boolean { return treeAdapter.isTextNode(node); } isCommentNode(node: any): boolean { return treeAdapter.isCommentNode(node); } isElementNode(node: any): boolean { return node ? treeAdapter.isElementNode(node) : false; } - hasShadowRoot(node: any): boolean { return isPresent(node.shadowRoot); } + hasShadowRoot(node: any): boolean { return node.shadowRoot != null; } isShadowRoot(node: any): boolean { return this.getShadowRoot(node) == node; } importIntoDoc(node: any): any { return this.clone(node); } adoptNode(node: any): any { return node; } @@ -529,7 +528,7 @@ export class Parse5DomAdapter extends DomAdapter { .replace(/\s*\+\s*/g, ' + ') .replace(/\s*>\s*/g, ' > ') .replace(/\[(\w+)=(\w+)\]/g, '[$1="$2"]')); - if (isBlank(parsedRule.declarations)) { + if (parsedRule.declarations == null) { continue; } for (let j = 0; j < parsedRule.declarations.length; j++) { @@ -566,7 +565,7 @@ export class Parse5DomAdapter extends DomAdapter { href = this.getHref(base); } // TODO(alxhub): Need relative path logic from BrowserDomAdapter here? - return isBlank(href) ? null : href; + return href == null ? null : href; } resetBaseElement(): void { throw 'not implemented'; } getHistory(): History { throw 'not implemented'; } diff --git a/modules/@angular/platform-server/src/server_renderer.ts b/modules/@angular/platform-server/src/server_renderer.ts index 8c6c09ef8b..b3d076fe45 100644 --- a/modules/@angular/platform-server/src/server_renderer.ts +++ b/modules/@angular/platform-server/src/server_renderer.ts @@ -7,11 +7,9 @@ */ import {DomElementSchemaRegistry} from '@angular/compiler'; -import {APP_ID, Inject, Injectable, NgZone, RenderComponentType, Renderer, RendererFactoryV2, RendererTypeV2, RendererV2, RootRenderer, ViewEncapsulation} from '@angular/core'; +import {APP_ID, Inject, Injectable, NgZone, RenderComponentType, Renderer, RendererFactoryV2, RendererTypeV2, RendererV2, RootRenderer, ViewEncapsulation, ɵstringify as stringify} from '@angular/core'; import {DOCUMENT, ɵNAMESPACE_URIS as NAMESPACE_URIS, ɵSharedStylesHost as SharedStylesHost, ɵflattenStyles as flattenStyles, ɵgetDOM as getDOM, ɵshimContentAttribute as shimContentAttribute, ɵshimHostAttribute as shimHostAttribute} from '@angular/platform-browser'; -import {isBlank, isPresent, stringify} from './facade/lang'; - const EMPTY_ARRAY: any[] = []; @Injectable() @@ -151,7 +149,7 @@ class DefaultServerRendererV2 implements RendererV2 { getDOM().setProperty(el, name, value); // Mirror property values for known HTML element properties in the attributes. const tagName = (el.tagName as string).toLowerCase(); - if (isPresent(value) && (typeof value === 'number' || typeof value == 'string') && + if (value != null && (typeof value === 'number' || typeof value == 'string') && this.schema.hasElement(tagName, EMPTY_ARRAY) && this.schema.hasProperty(tagName, name, EMPTY_ARRAY) && this._isSafeToReflectProperty(tagName, name)) { diff --git a/modules/@angular/platform-server/testing/facade b/modules/@angular/platform-server/testing/facade deleted file mode 120000 index e084c803c6..0000000000 --- a/modules/@angular/platform-server/testing/facade +++ /dev/null @@ -1 +0,0 @@ -../../facade/src \ No newline at end of file diff --git a/modules/@angular/platform-webworker-dynamic/src/facade b/modules/@angular/platform-webworker-dynamic/src/facade deleted file mode 120000 index e084c803c6..0000000000 --- a/modules/@angular/platform-webworker-dynamic/src/facade +++ /dev/null @@ -1 +0,0 @@ -../../facade/src \ No newline at end of file diff --git a/modules/@angular/platform-webworker/src/facade b/modules/@angular/platform-webworker/src/facade deleted file mode 120000 index e084c803c6..0000000000 --- a/modules/@angular/platform-webworker/src/facade +++ /dev/null @@ -1 +0,0 @@ -../../facade/src \ No newline at end of file diff --git a/modules/@angular/platform-webworker/src/web_workers/shared/client_message_broker.ts b/modules/@angular/platform-webworker/src/web_workers/shared/client_message_broker.ts index c8ea07dfe8..dde8d5e794 100644 --- a/modules/@angular/platform-webworker/src/web_workers/shared/client_message_broker.ts +++ b/modules/@angular/platform-webworker/src/web_workers/shared/client_message_broker.ts @@ -6,10 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -import {EventEmitter, Injectable, Type} from '@angular/core'; - -import {stringify} from '../../facade/lang'; - +import {EventEmitter, Injectable, Type, ɵstringify as stringify} from '@angular/core'; import {MessageBus} from './message_bus'; import {Serializer, SerializerTypes} from './serializer'; diff --git a/modules/@angular/platform-webworker/src/web_workers/shared/serializer.ts b/modules/@angular/platform-webworker/src/web_workers/shared/serializer.ts index 775bd2aa8d..277a615e19 100644 --- a/modules/@angular/platform-webworker/src/web_workers/shared/serializer.ts +++ b/modules/@angular/platform-webworker/src/web_workers/shared/serializer.ts @@ -6,10 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -import {Injectable, RenderComponentType, RendererTypeV2, Type} from '@angular/core'; - -import {stringify} from '../../facade/lang'; - +import {Injectable, RenderComponentType, RendererTypeV2, Type, ɵstringify as stringify} from '@angular/core'; import {RenderStore} from './render_store'; diff --git a/modules/@angular/platform-webworker/test/web_workers/shared/web_worker_test_util.ts b/modules/@angular/platform-webworker/test/web_workers/shared/web_worker_test_util.ts index 4db1667453..21c43c2aa6 100644 --- a/modules/@angular/platform-webworker/test/web_workers/shared/web_worker_test_util.ts +++ b/modules/@angular/platform-webworker/test/web_workers/shared/web_worker_test_util.ts @@ -10,7 +10,6 @@ import {Type} from '@angular/core'; import {NgZone} from '@angular/core/src/zone/ng_zone'; import {ClientMessageBroker, ClientMessageBrokerFactory_, UiArguments} from '@angular/platform-webworker/src/web_workers/shared/client_message_broker'; import {MessageBus, MessageBusSink, MessageBusSource} from '@angular/platform-webworker/src/web_workers/shared/message_bus'; -import {isPresent} from '../../../src/facade/lang'; import {SpyMessageBroker} from '../worker/spies'; import {MockEventEmitter} from './mock_event_emitter'; @@ -44,12 +43,12 @@ export function expectBrokerCall( handler?: (..._: any[]) => Promise| void): void { broker.spy('runOnService').and.callFake((args: UiArguments, returnType: Type) => { expect(args.method).toEqual(methodName); - if (isPresent(vals)) { + if (vals != null) { expect(args.args.length).toEqual(vals.length); vals.forEach((v, i) => { expect(v).toEqual(args.args[i].value); }); } let promise: Promise|void = null; - if (isPresent(handler)) { + if (handler != null) { const givenValues = args.args.map((arg) => arg.value); if (givenValues.length > 0) { promise = handler(givenValues); diff --git a/modules/@angular/router/testing/facade b/modules/@angular/router/testing/facade deleted file mode 120000 index e084c803c6..0000000000 --- a/modules/@angular/router/testing/facade +++ /dev/null @@ -1 +0,0 @@ -../../facade/src \ No newline at end of file diff --git a/modules/@angular/upgrade/src/facade b/modules/@angular/upgrade/src/facade deleted file mode 120000 index e084c803c6..0000000000 --- a/modules/@angular/upgrade/src/facade +++ /dev/null @@ -1 +0,0 @@ -../../facade/src \ No newline at end of file diff --git a/modules/@angular/upgrade/src/static/upgrade_component.ts b/modules/@angular/upgrade/src/static/upgrade_component.ts index 29311e5b41..97856d141e 100644 --- a/modules/@angular/upgrade/src/static/upgrade_component.ts +++ b/modules/@angular/upgrade/src/static/upgrade_component.ts @@ -6,12 +6,10 @@ * found in the LICENSE file at https://angular.io/license */ -import {DoCheck, ElementRef, EventEmitter, Injector, OnChanges, OnDestroy, OnInit, SimpleChanges} from '@angular/core'; - +import {DoCheck, ElementRef, EventEmitter, Injector, OnChanges, OnDestroy, OnInit, SimpleChanges, ɵlooseIdentical as looseIdentical} from '@angular/core'; import * as angular from '../common/angular1'; import {$COMPILE, $CONTROLLER, $HTTP_BACKEND, $INJECTOR, $SCOPE, $TEMPLATE_CACHE} from '../common/constants'; import {controllerKey} from '../common/util'; -import {looseIdentical} from '../facade/lang'; const REQUIRE_PREFIX_RE = /^(\^\^?)?(\?)?(\^\^?)?/; const NOT_SUPPORTED: any = 'NOT_SUPPORTED'; diff --git a/modules/benchmarks/src/old/compiler/selector_benchmark.ts b/modules/benchmarks/src/old/compiler/selector_benchmark.ts index a4141784df..d1812a2d6d 100644 --- a/modules/benchmarks/src/old/compiler/selector_benchmark.ts +++ b/modules/benchmarks/src/old/compiler/selector_benchmark.ts @@ -7,7 +7,6 @@ */ import {CssSelector, SelectorMatcher} from '@angular/compiler/src/selector'; -import {Math} from '@angular/facade/lang'; import {BrowserDomAdapter} from '@angular/platform-browser/src/browser/browser_adapter'; import {bindAction, getIntParameter} from '@angular/testing/src/benchmark_util'; diff --git a/modules/benchmarks/src/old/naive_infinite_scroll/app.ts b/modules/benchmarks/src/old/naive_infinite_scroll/app.ts index 2eb1fa40c5..7cd59bcf85 100644 --- a/modules/benchmarks/src/old/naive_infinite_scroll/app.ts +++ b/modules/benchmarks/src/old/naive_infinite_scroll/app.ts @@ -49,7 +49,7 @@ export class App { bindAction('#reset-btn', () => { this._getScrollDiv().scrollTop = 0; const existingMarker = this._locateFinishedMarker(); - if (isPresent(existingMarker)) { + if (existingMarker != null) { DOM.removeChild(document.body, existingMarker); } }); @@ -76,7 +76,7 @@ export class App { // Puts a marker indicating that the test is finished. private _scheduleFinishedMarker() { const existingMarker = this._locateFinishedMarker(); - if (isPresent(existingMarker)) { + if (existingMarker != null) { // Nothing to do, the marker is already there return; } diff --git a/tools/@angular/tsc-wrapped/src/collector.ts b/tools/@angular/tsc-wrapped/src/collector.ts index aed013536c..15658ee9dc 100644 --- a/tools/@angular/tsc-wrapped/src/collector.ts +++ b/tools/@angular/tsc-wrapped/src/collector.ts @@ -8,7 +8,7 @@ import * as ts from 'typescript'; -import {Evaluator, errorSymbol, isPrimitive} from './evaluator'; +import {Evaluator, errorSymbol} from './evaluator'; import {ClassMetadata, ConstructorMetadata, FunctionMetadata, MemberMetadata, MetadataEntry, MetadataError, MetadataMap, MetadataSymbolicBinaryExpression, MetadataSymbolicCallExpression, MetadataSymbolicExpression, MetadataSymbolicIfExpression, MetadataSymbolicIndexExpression, MetadataSymbolicPrefixExpression, MetadataSymbolicReferenceExpression, MetadataSymbolicSelectExpression, MetadataSymbolicSpreadExpression, MetadataValue, MethodMetadata, ModuleExportMetadata, ModuleMetadata, VERSION, isClassMetadata, isConstructorMetadata, isFunctionMetadata, isMetadataError, isMetadataGlobalReferenceExpression, isMetadataSymbolicExpression, isMetadataSymbolicReferenceExpression, isMetadataSymbolicSelectExpression, isMethodMetadata} from './schema'; import {Symbols} from './symbols'; @@ -431,7 +431,8 @@ export class MetadataCollector { metadata[exportedIdentifierName(nameNode)] = recordEntry(varValue, node); exported = true; } - if (isPrimitive(varValue)) { + if (typeof varValue == 'string' || typeof varValue == 'number' || + typeof varValue == 'boolean') { locals.define(nameNode.text, varValue); } else if (!exported) { if (varValue && !isMetadataError(varValue)) {