Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(all): migrate to package:web #75

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
108 changes: 54 additions & 54 deletions ngcompiler/lib/v1/src/compiler/identifiers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -275,68 +275,68 @@ class Identifiers {

// Runtime is initialized by output interpreter. Compiler executes in VM and
// can't import dart:html to initialize here.
static var commentNode =
CompileIdentifierMetadata(name: 'Comment', moduleUrl: 'dart:html');
static var textNode =
CompileIdentifierMetadata(name: 'Text', moduleUrl: 'dart:html');
static var document =
CompileIdentifierMetadata(name: 'document', moduleUrl: 'dart:html');
static var commentNode = CompileIdentifierMetadata(
name: 'Comment', moduleUrl: 'package:web/web.dart');
static var textNode = CompileIdentifierMetadata(
name: 'Text', moduleUrl: 'package:web/web.dart');
static var document = CompileIdentifierMetadata(
name: 'document', moduleUrl: 'package:web/web.dart');
static final documentFragment = CompileIdentifierMetadata(
name: 'DocumentFragment', moduleUrl: 'dart:html');
static final element =
CompileIdentifierMetadata(name: 'Element', moduleUrl: 'dart:html');
name: 'DocumentFragment', moduleUrl: 'package:web/web.dart');
static final element = CompileIdentifierMetadata(
name: 'Element', moduleUrl: 'package:web/web.dart');
static final elementToken = identifierToken(element);
static final htmlElement =
CompileIdentifierMetadata(name: 'HtmlElement', moduleUrl: 'dart:html');
static final htmlElement = CompileIdentifierMetadata(
name: 'HtmlElement', moduleUrl: 'package:web/web.dart');
static final htmlElementToken = identifierToken(htmlElement);
static final svgSvgElement =
CompileIdentifierMetadata(name: 'SvgSvgElement', moduleUrl: 'dart:svg');
static final svgElement =
CompileIdentifierMetadata(name: 'SvgElement', moduleUrl: 'dart:svg');
static final anchorElement =
CompileIdentifierMetadata(name: 'AnchorElement', moduleUrl: 'dart:html');
static final divElement =
CompileIdentifierMetadata(name: 'DivElement', moduleUrl: 'dart:html');
static final areaElement =
CompileIdentifierMetadata(name: 'AreaElement', moduleUrl: 'dart:html');
static final audioElement =
CompileIdentifierMetadata(name: 'AudioElement', moduleUrl: 'dart:html');
static final buttonElement =
CompileIdentifierMetadata(name: 'ButtonElement', moduleUrl: 'dart:html');
static final canvasElement =
CompileIdentifierMetadata(name: 'CanvasElement', moduleUrl: 'dart:html');
static final formElement =
CompileIdentifierMetadata(name: 'FormElement', moduleUrl: 'dart:html');
static final iframeElement =
CompileIdentifierMetadata(name: 'IFrameElement', moduleUrl: 'dart:html');
static final imageElement =
CompileIdentifierMetadata(name: 'ImageElement', moduleUrl: 'dart:html');
static final inputElement =
CompileIdentifierMetadata(name: 'InputElement', moduleUrl: 'dart:html');
static final svgSvgElement = CompileIdentifierMetadata(
name: 'SVGSVGElement', moduleUrl: 'package:web/web.dart');
static final svgElement = CompileIdentifierMetadata(
name: 'SVGElement', moduleUrl: 'package:web/web.dart');
static final anchorElement = CompileIdentifierMetadata(
name: 'HTMLAnchorElement', moduleUrl: 'package:web/web.dart');
static final divElement = CompileIdentifierMetadata(
name: 'HTMLDivElement', moduleUrl: 'package:web/web.dart');
static final areaElement = CompileIdentifierMetadata(
name: 'HTMLAreaElement', moduleUrl: 'package:web/web.dart');
static final audioElement = CompileIdentifierMetadata(
name: 'HTMLAudioElement', moduleUrl: 'package:web/web.dart');
static final buttonElement = CompileIdentifierMetadata(
name: 'HTMLButtonElement', moduleUrl: 'package:web/web.dart');
static final canvasElement = CompileIdentifierMetadata(
name: 'HTMLCanvasElement', moduleUrl: 'package:web/web.dart');
static final formElement = CompileIdentifierMetadata(
name: 'HTMLFormElement', moduleUrl: 'package:web/web.dart');
static final iframeElement = CompileIdentifierMetadata(
name: 'HTMLIFrameElement', moduleUrl: 'package:web/web.dart');
static final imageElement = CompileIdentifierMetadata(
name: 'HTMLImageElement', moduleUrl: 'package:web/web.dart');
static final inputElement = CompileIdentifierMetadata(
name: 'HTMLInputElement', moduleUrl: 'package:web/web.dart');
static final textareaElement = CompileIdentifierMetadata(
name: 'TextAreaElement', moduleUrl: 'dart:html');
static final mediaElement =
CompileIdentifierMetadata(name: 'MediaElement', moduleUrl: 'dart:html');
static final menuElement =
CompileIdentifierMetadata(name: 'MenuElement', moduleUrl: 'dart:html');
name: 'HTMLTextAreaElement', moduleUrl: 'package:web/web.dart');
static final mediaElement = CompileIdentifierMetadata(
name: 'HTMLMediaElement', moduleUrl: 'package:web/web.dart');
static final menuElement = CompileIdentifierMetadata(
name: 'HTMLMenuElement', moduleUrl: 'package:web/web.dart');
static final nodeTreeSanitizer = CompileIdentifierMetadata(
name: 'NodeTreeSanitizer', moduleUrl: 'dart:html');
static final optionElement =
CompileIdentifierMetadata(name: 'OptionElement', moduleUrl: 'dart:html');
static final oListElement =
CompileIdentifierMetadata(name: 'OListElement', moduleUrl: 'dart:html');
static final selectElement =
CompileIdentifierMetadata(name: 'SelectElement', moduleUrl: 'dart:html');
static final tableElement =
CompileIdentifierMetadata(name: 'TableElement', moduleUrl: 'dart:html');
static final optionElement = CompileIdentifierMetadata(
name: 'HTMLOptionElement', moduleUrl: 'package:web/web.dart');
static final oListElement = CompileIdentifierMetadata(
name: 'HTMLOListElement', moduleUrl: 'package:web/web.dart');
static final selectElement = CompileIdentifierMetadata(
name: 'HTMLSelectElement', moduleUrl: 'package:web/web.dart');
static final tableElement = CompileIdentifierMetadata(
name: 'HTMLTableElement', moduleUrl: 'package:web/web.dart');
static final tableRowElement = CompileIdentifierMetadata(
name: 'TableRowElement', moduleUrl: 'dart:html');
name: 'HTMLTableRowElement', moduleUrl: 'package:web/web.dart');
static final tableColElement = CompileIdentifierMetadata(
name: 'TableColElement', moduleUrl: 'dart:html');
static final uListElement =
CompileIdentifierMetadata(name: 'UListElement', moduleUrl: 'dart:html');
static final node =
CompileIdentifierMetadata(name: 'Node', moduleUrl: 'dart:html');
name: 'HTMLTableColElement', moduleUrl: 'package:web/web.dart');
static final uListElement = CompileIdentifierMetadata(
name: 'HTMLUListElement', moduleUrl: 'package:web/web.dart');
static final node = CompileIdentifierMetadata(
name: 'Node', moduleUrl: 'package:web/web.dart');

/// A class used for message internationalization.
static final intl = CompileIdentifierMetadata(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ class _UpdateStatementsVisitor
: currValExpr.callMethod('toString', []);
final styleWithUnit = styleString.plus(o.literal(styleBinding.unit));
styleValueExpr =
currValExpr.isBlank().conditional(o.nullExpr, styleWithUnit);
currValExpr.isBlank().conditional(o.escapedString(''), styleWithUnit);
} else {
styleValueExpr = bindingSource.isString
? currValExpr
Expand Down
7 changes: 5 additions & 2 deletions ngdart/lib/src/runtime/dom_events.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ class EventManager {
// If the view compiler knows that a given event is a DOM event (i.e.
// "click"), it will never be called into EventManager. But of course the
// browser APIs change, so this is the final fallback.
element.addEventListener(name, callback.toJS);
//
// TODO(GZGavinZhao): the `Event` signature should progagate back to
// `addEventListener` for stronger type guarantees.
element.addEventListener(name, ((Event event) => callback(event)).toJS);
}
}

Expand Down Expand Up @@ -88,7 +91,7 @@ class _KeyEventsHandler {

element.addEventListener(
parsed.domEventName,
(event) {
(Event event) {
if (event is KeyboardEvent && parsed.matches(event)) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be event.isA<KeyboardEvent>().

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isA() requires to bump SDK to 3.4.0

callback(event);
}
Expand Down
Loading