From 3e65d1458e7ec4073763ce72c1995c6addb87249 Mon Sep 17 00:00:00 2001 From: Jacob Richman Date: Tue, 12 Jan 2016 16:38:36 -0800 Subject: [PATCH] fix(Dart): make some playground samples run with Dart Dev Compiler Resolve all invalid field override errors, workaround current reflection limitations in Dart Dev Compiler. todo, hello_world and key_events samples now work with Dart Dev Compiler. BREAKING CHANGE: remove TemplateRef.elementRef setter Closes #6441 --- .../angular2/src/core/linker/template_ref.ts | 2 +- modules/angular2/src/facade/exceptions.dart | 18 ++++++++++++------ .../angular2/src/platform/dom/dom_adapter.ts | 5 ++++- .../src/platform/dom/events/dom_events.ts | 2 -- modules/angular2/test/public_api_spec.ts | 1 - .../change_detector_codegen.dart | 2 +- 6 files changed, 18 insertions(+), 12 deletions(-) diff --git a/modules/angular2/src/core/linker/template_ref.ts b/modules/angular2/src/core/linker/template_ref.ts index c26df74a94..ad934be9a1 100644 --- a/modules/angular2/src/core/linker/template_ref.ts +++ b/modules/angular2/src/core/linker/template_ref.ts @@ -25,7 +25,7 @@ export abstract class TemplateRef { * */ // TODO(i): rename to anchor or location - elementRef: ElementRef; + get elementRef(): ElementRef { return null; } } export class TemplateRef_ extends TemplateRef { diff --git a/modules/angular2/src/facade/exceptions.dart b/modules/angular2/src/facade/exceptions.dart index 77f9accfbf..5badc6c5d6 100644 --- a/modules/angular2/src/facade/exceptions.dart +++ b/modules/angular2/src/facade/exceptions.dart @@ -4,9 +4,11 @@ import 'exception_handler.dart'; export 'exception_handler.dart'; class BaseException extends Error { - final String message; + final String _message; - BaseException([this.message]); + BaseException([this._message]); + + String get message => _message; String toString() { return this.message; @@ -14,16 +16,16 @@ class BaseException extends Error { } class WrappedException extends Error { - final dynamic context; - final String wrapperMessage; + final dynamic _context; + final String _wrapperMessage; final originalException; final originalStack; WrappedException( - [this.wrapperMessage, + [this._wrapperMessage, this.originalException, this.originalStack, - this.context]); + this._context]); get message { return ExceptionHandler.exceptionToString(this); @@ -32,6 +34,10 @@ class WrappedException extends Error { String toString() { return this.message; } + + dynamic get context => _context; + + String get wrapperMessage => _wrapperMessage; } Error makeTypeError([String message = ""]) { diff --git a/modules/angular2/src/platform/dom/dom_adapter.ts b/modules/angular2/src/platform/dom/dom_adapter.ts index 19416fe740..6f183da665 100644 --- a/modules/angular2/src/platform/dom/dom_adapter.ts +++ b/modules/angular2/src/platform/dom/dom_adapter.ts @@ -30,7 +30,10 @@ export abstract class DomAdapter { * Maps attribute names to their corresponding property names for cases * where attribute name doesn't match property name. */ - attrToPropMap: {[key: string]: string}; + get attrToPropMap(): {[key: string]: string} { return this._attrToPropMap; }; + set attrToPropMap(value: {[key: string]: string}) { this._attrToPropMap = value; }; + /** @internal */ + _attrToPropMap: {[key: string]: string}; abstract parse(templateHtml: string); abstract query(selector: string): any; diff --git a/modules/angular2/src/platform/dom/events/dom_events.ts b/modules/angular2/src/platform/dom/events/dom_events.ts index a90480d992..8bee803bfe 100644 --- a/modules/angular2/src/platform/dom/events/dom_events.ts +++ b/modules/angular2/src/platform/dom/events/dom_events.ts @@ -4,8 +4,6 @@ import {EventManagerPlugin, EventManager} from './event_manager'; @Injectable() export class DomEventsPlugin extends EventManagerPlugin { - manager: EventManager; - // This plugin should come last in the list of plugins, because it accepts all // events. supports(eventName: string): boolean { return true; } diff --git a/modules/angular2/test/public_api_spec.ts b/modules/angular2/test/public_api_spec.ts index d18860290b..f27dedfe35 100644 --- a/modules/angular2/test/public_api_spec.ts +++ b/modules/angular2/test/public_api_spec.ts @@ -1224,7 +1224,6 @@ var NG_CORE = [ 'SimpleChange.isFirstChange()', 'TemplateRef', 'TemplateRef.elementRef', - 'TemplateRef.elementRef=', /* Abstract method 'TemplateRef.hasLocal()', diff --git a/modules_dart/transform/lib/src/transform/template_compiler/change_detector_codegen.dart b/modules_dart/transform/lib/src/transform/template_compiler/change_detector_codegen.dart index 88f3d417a3..a496ddc65e 100644 --- a/modules_dart/transform/lib/src/transform/template_compiler/change_detector_codegen.dart +++ b/modules_dart/transform/lib/src/transform/template_compiler/change_detector_codegen.dart @@ -225,7 +225,7 @@ class _CodegenState { List codes = []; _endOfBlockIdxs.clear(); - ListWrapper.forEachWithIndex(eb.records, (r, i) { + ListWrapper.forEachWithIndex(eb.records, (_, i) { var code; var r = eb.records[i];